Skip to content

Commit ffd1989

Browse files
committed
chore: Bump RN to 0.62
We only bump to 0.62 because react-native-macos 0.63 isn't out yet. To simplify our lives, we stay in sync to avoid any potential issues from having both 0.62 and 0.63 installed.
1 parent fdf46d4 commit ffd1989

35 files changed

+3036
-5312
lines changed

.flowconfig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
[ignore]
2+
; Build output
3+
<PROJECT_ROOT>/lib/
4+
25
; We fork some components by platform
36
.*/*[.]android.js
47

@@ -21,7 +24,7 @@ node_modules/warning/.*
2124
[include]
2225

2326
[libs]
24-
node_modules/react-native/Libraries/react-native/react-native-interface.js
27+
node_modules/react-native/interface.js
2528
node_modules/react-native/flow/
2629

2730
[options]
@@ -41,9 +44,8 @@ server.max_workers=1
4144
# Support the library import in examples
4245
module.name_mapper='^\@react-native-async-storage/async-storage$' -> '<PROJECT_ROOT>/src/AsyncStorage.js'
4346

44-
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
4547
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
46-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
48+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
4749

4850
suppress_type=$FlowIssue
4951
suppress_type=$FlowFixMe
@@ -77,4 +79,4 @@ untyped-import
7779
untyped-type-import
7880

7981
[version]
80-
^0.105.0
82+
^0.113.0

example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ buck-out/
5757

5858
# CocoaPods
5959
/ios/Pods/
60+
/macos/Pods/
6061
Podfile.lock

example/__tests__/App.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,31 +79,31 @@ describe('Async Storage mock functionality', () => {
7979
});
8080

8181
describe('Callback based', () => {
82-
it('can read/write data to/from storage', done => {
82+
it('can read/write data to/from storage', (done) => {
8383
const newData = Math.floor(Math.random() * 1000);
8484

85-
AsyncStorage.setItem('key', newData, function() {
86-
AsyncStorage.getItem('key', function(_, value) {
85+
AsyncStorage.setItem('key', newData, function () {
86+
AsyncStorage.getItem('key', function (_, value) {
8787
expect(value).toBe(newData);
8888
done();
89-
}).catch(e => done.fail(e));
89+
}).catch((e) => done.fail(e));
9090
});
9191
});
92-
it('can clear storage', done => {
92+
it('can clear storage', (done) => {
9393
AsyncStorage.setItem('temp_key', Math.random() * 1000, () => {
9494
AsyncStorage.getItem('temp_key', (_, currentValue) => {
9595
expect(currentValue).not.toBeNull();
9696
AsyncStorage.clear(() => {
9797
AsyncStorage.getItem('temp_key', (_, value) => {
9898
expect(value).toBeNull();
9999
done();
100-
}).catch(e => done.fail(e));
100+
}).catch((e) => done.fail(e));
101101
});
102-
}).catch(e => done.fail(e));
102+
}).catch((e) => done.fail(e));
103103
});
104104
});
105105

106-
it('can clear entries in storage', done => {
106+
it('can clear entries in storage', (done) => {
107107
AsyncStorage.setItem('random1', Math.random() * 1000, () => {
108108
AsyncStorage.setItem('random2', Math.random() * 1000, () => {
109109
AsyncStorage.getItem('random1', (_, data1) => {
@@ -118,17 +118,17 @@ describe('Async Storage mock functionality', () => {
118118
expect(value1).toBeNull();
119119
expect(value2).toBeNull();
120120
done();
121-
}).catch(e => done.fail(e));
121+
}).catch((e) => done.fail(e));
122122
});
123123
});
124124
});
125-
}).catch(e => done.fail(e));
125+
}).catch((e) => done.fail(e));
126126
});
127127
});
128128
});
129129
});
130130

131-
it('can use merge with current data in storage', done => {
131+
it('can use merge with current data in storage', (done) => {
132132
let originalPerson = {
133133
name: 'Jerry',
134134
age: 21,
@@ -149,7 +149,7 @@ describe('Async Storage mock functionality', () => {
149149
expect(person.characteristics).toHaveProperty('hair', 'red');
150150
expect(person.characteristics).toHaveProperty('shoeSize', 40);
151151
done();
152-
}).catch(e => done.fail(e));
152+
}).catch((e) => done.fail(e));
153153
});
154154
});
155155
});

example/app.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
22
"name": "AsyncStorageExample",
3-
"displayName": "AsyncStorageExample"
4-
}
3+
"displayName": "AsyncStorageExample",
4+
"components": [
5+
{
6+
"appKey": "AsyncStorageExample"
7+
}
8+
]
9+
}

example/examples/GetSetClear.js

Lines changed: 38 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,76 +8,62 @@
88
* @flow
99
*/
1010

11-
import React, {Component} from 'react';
11+
import React from 'react';
1212
import {StyleSheet, Text, View, Button} from 'react-native';
1313

1414
import AsyncStorage from '@react-native-async-storage/async-storage';
1515

1616
type Props = {};
17-
type State = {
18-
storedNumber: string,
19-
needRestart: boolean,
20-
};
21-
export default class GetSet extends Component<Props, State> {
22-
state = {
23-
storedNumber: '',
24-
needRestart: false,
25-
};
2617

27-
async componentWillMount() {
28-
const storedNumber = await AsyncStorage.getItem(STORAGE_KEY);
29-
if (storedNumber) {
30-
this.setState({
31-
storedNumber,
32-
});
33-
}
34-
}
18+
export default function GetSet(_: Props) {
19+
const [storedNumber, setStoredNumber] = React.useState('');
20+
const [needsRestart, setNeedsRestart] = React.useState(false);
3521

36-
increaseByTen = async () => {
37-
const {storedNumber} = this.state;
22+
React.useEffect(() => {
23+
AsyncStorage.getItem(STORAGE_KEY).then((value) => {
24+
if (value) {
25+
setStoredNumber(value);
26+
}
27+
});
28+
}, []);
3829

30+
const increaseByTen = React.useCallback(async () => {
3931
const newNumber = +storedNumber > 0 ? +storedNumber + 10 : 10;
4032

4133
await AsyncStorage.setItem(STORAGE_KEY, `${newNumber}`);
4234

43-
this.setState({storedNumber: `${newNumber}`, needRestart: true});
44-
};
35+
setStoredNumber(`${newNumber}`);
36+
setNeedsRestart(true);
37+
}, [setNeedsRestart, setStoredNumber, storedNumber]);
4538

46-
clearItem = async () => {
39+
const clearItem = React.useCallback(async () => {
4740
await AsyncStorage.removeItem(STORAGE_KEY);
48-
49-
this.setState({needRestart: true});
50-
};
51-
52-
render() {
53-
const {storedNumber, needRestart} = this.state;
54-
return (
55-
<View>
56-
<Text style={styles.text}>Currently stored: </Text>
57-
<Text testID="storedNumber_text" style={styles.text}>
58-
{storedNumber}
59-
</Text>
60-
61-
<Button
62-
testID="increaseByTen_button"
63-
title="Increase by 10"
64-
onPress={this.increaseByTen}
65-
/>
66-
67-
<Button
68-
testID="clear_button"
69-
title="Clear item"
70-
onPress={this.clearItem}
71-
/>
72-
73-
{needRestart ? <Text>Hit restart to see effect</Text> : null}
74-
</View>
75-
);
76-
}
41+
setNeedsRestart(true);
42+
}, [setNeedsRestart]);
43+
44+
return (
45+
<View>
46+
<Text style={styles.text}>Currently stored: </Text>
47+
<Text testID="storedNumber_text" style={styles.text}>
48+
{storedNumber}
49+
</Text>
50+
51+
<Button
52+
testID="increaseByTen_button"
53+
title="Increase by 10"
54+
onPress={increaseByTen}
55+
/>
56+
57+
<Button testID="clear_button" title="Clear item" onPress={clearItem} />
58+
59+
{needsRestart ? <Text>Hit restart to see effect</Text> : null}
60+
</View>
61+
);
7762
}
7863

7964
const styles = StyleSheet.create({
8065
text: {
66+
color: '#000000',
8167
fontSize: 20,
8268
textAlign: 'center',
8369
margin: 10,

example/examples/MergeItem.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export default class Merge extends Component<Props, State> {
147147
}>{`${name} is ${age}, has ${trait1} eyes and shoe size of ${trait2}.`}</Text>
148148
</View>
149149

150-
{INPUTS.map(input => {
150+
{INPUTS.map((input) => {
151151
const isTraitsPart = input.stateFragment.includes('trait');
152152

153153
const value = isTraitsPart
@@ -156,15 +156,22 @@ export default class Merge extends Component<Props, State> {
156156
: // $FlowFixMe
157157
this.state[input.stateFragment];
158158

159-
const onChangeHandler = text => {
159+
const onChangeHandler = (text) => {
160160
isTraitsPart
161161
? this.setState(({traits: currentTraits}) => ({
162162
traits: {
163+
// $FlowFixMe
163164
...currentTraits,
165+
// $FlowFixMe
164166
[input.stateFragment]: text,
165167
},
166168
}))
167-
: this.setState({[input.stateFragment]: text});
169+
: this.setState((state) => ({
170+
// $FlowFixMe
171+
...state,
172+
// $FlowFixMe
173+
[input.stateFragment]: text,
174+
}));
168175
};
169176

170177
return (

example/ios/AsyncStorageExample.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@
373373
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
374374
GCC_WARN_UNUSED_FUNCTION = YES;
375375
GCC_WARN_UNUSED_VARIABLE = YES;
376-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
376+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
377377
MTL_ENABLE_DEBUG_INFO = YES;
378378
ONLY_ACTIVE_ARCH = YES;
379379
SDKROOT = iphoneos;
@@ -419,7 +419,7 @@
419419
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
420420
GCC_WARN_UNUSED_FUNCTION = YES;
421421
GCC_WARN_UNUSED_VARIABLE = YES;
422-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
422+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
423423
MTL_ENABLE_DEBUG_INFO = NO;
424424
SDKROOT = iphoneos;
425425
VALIDATE_PRODUCT = YES;

example/ios/Podfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
source 'https://cdn.cocoapods.org/'
2-
platform :ios, '9.0'
2+
platform :ios, '12.0'
33
require_relative '../../node_modules/@react-native-community/cli-platform-ios/native_modules'
44

55
target 'AsyncStorageExample' do
6-
# Pods for AsyncStorageExample
7-
pod 'RNCAsyncStorage', :path => "../.."
86
pod 'FBLazyVector', :path => "../../node_modules/react-native/Libraries/FBLazyVector"
97
pod 'FBReactNativeSpec', :path => "../../node_modules/react-native/Libraries/FBReactNativeSpec"
108
pod 'RCTRequired', :path => "../../node_modules/react-native/Libraries/RCTRequired"
@@ -28,13 +26,15 @@ target 'AsyncStorageExample' do
2826
pod 'React-jsi', :path => '../../node_modules/react-native/ReactCommon/jsi'
2927
pod 'React-jsiexecutor', :path => '../../node_modules/react-native/ReactCommon/jsiexecutor'
3028
pod 'React-jsinspector', :path => '../../node_modules/react-native/ReactCommon/jsinspector'
31-
pod 'ReactCommon/jscallinvoker', :path => "../../node_modules/react-native/ReactCommon"
29+
pod 'ReactCommon/callinvoker', :path => "../../node_modules/react-native/ReactCommon"
3230
pod 'ReactCommon/turbomodule/core', :path => "../../node_modules/react-native/ReactCommon"
33-
pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga'
31+
pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
3432

3533
pod 'DoubleConversion', :podspec => '../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
3634
pod 'glog', :podspec => '../../node_modules/react-native/third-party-podspecs/glog.podspec'
3735
pod 'Folly', :podspec => '../../node_modules/react-native/third-party-podspecs/Folly.podspec'
3836

37+
pod 'RNCAsyncStorage', :path => "../.."
38+
3939
use_native_modules!
40-
end
40+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require 'json'
2+
3+
package = JSON.parse(File.read(File.join('..', '..', 'package.json')))
4+
5+
Pod::Spec.new do |s|
6+
s.name = 'AsyncStorageExample-UITests'
7+
s.version = package['version']
8+
s.author = { package['author']['name'] => package['author']['email'] }
9+
s.license = package['license']
10+
s.homepage = package['homepage']
11+
s.source = { git: package['repository']['url'] }
12+
s.summary = 'AsyncStorageExample UI tests'
13+
14+
s.ios.deployment_target = '12.0'
15+
s.osx.deployment_target = '10.14'
16+
17+
s.dependency 'React'
18+
s.dependency 'ReactTestApp-DevSupport'
19+
20+
s.framework = 'XCTest'
21+
s.user_target_xcconfig = { 'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES' => '$(inherited)' }
22+
23+
s.source_files = 'AsyncStorageExample-macOSUITests/**/*.{m,swift}'
24+
end

example/macos/AsyncStorageExample-macOS/AppDelegate.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)