Skip to content

Commit 9ad0710

Browse files
committed
chore: Bump RN to 0.62
We only bump to 0.62 because react-native-macos isn't 0.63 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 ce4f970 commit 9ad0710

File tree

12 files changed

+2953
-2306
lines changed

12 files changed

+2953
-2306
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/__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/examples/GetSetClear.js

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,72 +8,57 @@
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({

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/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

jest/async-storage-mock.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const asMock = {
3434
multiSet: jest.fn(_multiSet),
3535
multiRemove: jest.fn(_multiRemove),
3636
multiMerge: jest.fn(_multiMerge),
37-
useAsyncStorage: jest.fn(key => {
37+
useAsyncStorage: jest.fn((key) => {
3838
return {
3939
getItem: (...args) => asMock.getItem(key, ...args),
4040
setItem: (...args) => asMock.setItem(key, ...args),
@@ -45,7 +45,7 @@ const asMock = {
4545
};
4646

4747
async function _multiSet(keyValuePairs, callback) {
48-
keyValuePairs.forEach(keyValue => {
48+
keyValuePairs.forEach((keyValue) => {
4949
const key = keyValue[0];
5050

5151
asMock.__INTERNAL_MOCK_STORAGE__[key] = keyValue[1];
@@ -55,7 +55,7 @@ async function _multiSet(keyValuePairs, callback) {
5555
}
5656

5757
async function _multiGet(keys, callback) {
58-
const values = keys.map(key => [
58+
const values = keys.map((key) => [
5959
key,
6060
asMock.__INTERNAL_MOCK_STORAGE__[key] || null,
6161
]);
@@ -65,7 +65,7 @@ async function _multiGet(keys, callback) {
6565
}
6666

6767
async function _multiRemove(keys, callback) {
68-
keys.forEach(key => {
68+
keys.forEach((key) => {
6969
if (asMock.__INTERNAL_MOCK_STORAGE__[key]) {
7070
delete asMock.__INTERNAL_MOCK_STORAGE__[key];
7171
}
@@ -88,7 +88,7 @@ async function _getAllKeys() {
8888
}
8989

9090
async function _multiMerge(keyValuePairs, callback) {
91-
keyValuePairs.forEach(keyValue => {
91+
keyValuePairs.forEach((keyValue) => {
9292
const key = keyValue[0];
9393
const value = JSON.parse(keyValue[1]);
9494

@@ -103,12 +103,12 @@ async function _multiMerge(keyValuePairs, callback) {
103103
return null;
104104
}
105105

106-
const _isObject = obj => typeof obj === 'object' && !Array.isArray(obj);
106+
const _isObject = (obj) => typeof obj === 'object' && !Array.isArray(obj);
107107
const _deepMergeInto = (oldObject, newObject) => {
108108
const newKeys = Object.keys(newObject);
109109
const mergedObject = oldObject;
110110

111-
newKeys.forEach(key => {
111+
newKeys.forEach((key) => {
112112
const oldValue = mergedObject[key];
113113
const newValue = newObject[key];
114114

package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,27 @@
6464
"@babel/core": "^7.6.2",
6565
"@babel/runtime": "^7.6.2",
6666
"@react-native-community/bob": "^0.14.0",
67-
"@react-native-community/cli": "^3.1.0",
68-
"@react-native-community/cli-platform-android": "^3.1.0",
69-
"@react-native-community/cli-platform-ios": "^3.1.0",
70-
"@react-native-community/eslint-config": "^0.0.5",
67+
"@react-native-community/cli": "^4.5.1",
68+
"@react-native-community/cli-platform-android": "^4.5.1",
69+
"@react-native-community/cli-platform-ios": "^4.5.0",
70+
"@react-native-community/eslint-config": "^2.0.0",
7171
"babel-jest": "^26.5.2",
7272
"babel-plugin-module-resolver": "3.1.3",
7373
"detox": "16.7.2",
74-
"eslint": "5.1.0",
75-
"expo": "36.0.2",
76-
"flow-bin": "0.105.2",
74+
"eslint": "^6.0.0",
75+
"expo": "^38.0.10",
76+
"flow-bin": "^0.113.0",
7777
"jest": "^26.5.3",
7878
"metro": "0.56.4",
79-
"metro-react-native-babel-preset": "^0.56.0",
80-
"react": "16.9.0",
81-
"react-dom": "16.9.0",
82-
"react-native": "0.61.5",
83-
"react-native-macos": "0.60.0-microsoft.50",
79+
"metro-react-native-babel-preset": "^0.58.0",
80+
"react": "16.11.0",
81+
"react-dom": "16.11.0",
82+
"react-native": "0.62.2",
83+
"react-native-macos": "0.62.16",
84+
"react-native-test-app": "^0.2.0",
8485
"react-native-web": "~0.12.0",
85-
"react-native-windows": "0.61.0",
86-
"react-test-renderer": "16.9.0"
86+
"react-native-windows": "0.62.13",
87+
"react-test-renderer": "16.11.0"
8788
},
8889
"jest": {
8990
"preset": "react-native",

0 commit comments

Comments
 (0)