Skip to content

chore: Bump RN to 0.62 #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[ignore]
; Build output
<PROJECT_ROOT>/lib/

; We fork some components by platform
.*/*[.]android.js

Expand All @@ -21,7 +24,7 @@ node_modules/warning/.*
[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/interface.js
node_modules/react-native/flow/

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

module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
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'
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'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
Expand Down Expand Up @@ -77,4 +79,4 @@ untyped-import
untyped-type-import

[version]
^0.105.0
^0.113.0
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ buck-out/

# CocoaPods
/ios/Pods/
/macos/Pods/
Podfile.lock
24 changes: 12 additions & 12 deletions example/__tests__/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,31 @@ describe('Async Storage mock functionality', () => {
});

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

AsyncStorage.setItem('key', newData, function() {
AsyncStorage.getItem('key', function(_, value) {
AsyncStorage.setItem('key', newData, function () {
AsyncStorage.getItem('key', function (_, value) {
expect(value).toBe(newData);
done();
}).catch(e => done.fail(e));
}).catch((e) => done.fail(e));
});
});
it('can clear storage', done => {
it('can clear storage', (done) => {
AsyncStorage.setItem('temp_key', Math.random() * 1000, () => {
AsyncStorage.getItem('temp_key', (_, currentValue) => {
expect(currentValue).not.toBeNull();
AsyncStorage.clear(() => {
AsyncStorage.getItem('temp_key', (_, value) => {
expect(value).toBeNull();
done();
}).catch(e => done.fail(e));
}).catch((e) => done.fail(e));
});
}).catch(e => done.fail(e));
}).catch((e) => done.fail(e));
});
});

it('can clear entries in storage', done => {
it('can clear entries in storage', (done) => {
AsyncStorage.setItem('random1', Math.random() * 1000, () => {
AsyncStorage.setItem('random2', Math.random() * 1000, () => {
AsyncStorage.getItem('random1', (_, data1) => {
Expand All @@ -118,17 +118,17 @@ describe('Async Storage mock functionality', () => {
expect(value1).toBeNull();
expect(value2).toBeNull();
done();
}).catch(e => done.fail(e));
}).catch((e) => done.fail(e));
});
});
});
}).catch(e => done.fail(e));
}).catch((e) => done.fail(e));
});
});
});
});

it('can use merge with current data in storage', done => {
it('can use merge with current data in storage', (done) => {
let originalPerson = {
name: 'Jerry',
age: 21,
Expand All @@ -149,7 +149,7 @@ describe('Async Storage mock functionality', () => {
expect(person.characteristics).toHaveProperty('hair', 'red');
expect(person.characteristics).toHaveProperty('shoeSize', 40);
done();
}).catch(e => done.fail(e));
}).catch((e) => done.fail(e));
});
});
});
Expand Down
9 changes: 7 additions & 2 deletions example/app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"name": "AsyncStorageExample",
"displayName": "AsyncStorageExample"
}
"displayName": "AsyncStorageExample",
"components": [
{
"appKey": "AsyncStorageExample"
}
]
}
92 changes: 38 additions & 54 deletions example/examples/GetSetClear.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,60 @@
* @flow
*/

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

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

type Props = {};
type State = {
storedNumber: string,
needRestart: boolean,
};
export default class GetSet extends Component<Props, State> {
state = {
storedNumber: '',
needRestart: false,
};
export default function GetSet() {
const [storedNumber, setStoredNumber] = React.useState('');
const [needsRestart, setNeedsRestart] = React.useState(false);

async componentWillMount() {
const storedNumber = await AsyncStorage.getItem(STORAGE_KEY);
if (storedNumber) {
this.setState({
storedNumber,
});
}
}

increaseByTen = async () => {
const {storedNumber} = this.state;
React.useEffect(() => {
AsyncStorage.getItem(STORAGE_KEY).then((value) => {
if (value) {
setStoredNumber(value);
}
});
}, []);

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

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

this.setState({storedNumber: `${newNumber}`, needRestart: true});
};
setStoredNumber(`${newNumber}`);
setNeedsRestart(true);
}, [setNeedsRestart, setStoredNumber, storedNumber]);

clearItem = async () => {
const clearItem = React.useCallback(async () => {
await AsyncStorage.removeItem(STORAGE_KEY);

this.setState({needRestart: true});
};

render() {
const {storedNumber, needRestart} = this.state;
return (
<View>
<Text style={styles.text}>Currently stored: </Text>
<Text testID="storedNumber_text" style={styles.text}>
{storedNumber}
</Text>

<Button
testID="increaseByTen_button"
title="Increase by 10"
onPress={this.increaseByTen}
/>

<Button
testID="clear_button"
title="Clear item"
onPress={this.clearItem}
/>

{needRestart ? <Text>Hit restart to see effect</Text> : null}
</View>
);
}
setNeedsRestart(true);
}, [setNeedsRestart]);

return (
<View>
<Text style={styles.text}>Currently stored: </Text>
<Text testID="storedNumber_text" style={styles.text}>
{storedNumber}
</Text>

<Button
testID="increaseByTen_button"
title="Increase by 10"
onPress={increaseByTen}
/>

<Button testID="clear_button" title="Clear item" onPress={clearItem} />

{needsRestart ? <Text>Hit restart to see effect</Text> : null}
</View>
);
}

const styles = StyleSheet.create({
text: {
color: '#000000',
fontSize: 20,
textAlign: 'center',
margin: 10,
Expand Down
13 changes: 10 additions & 3 deletions example/examples/MergeItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default class Merge extends Component<Props, State> {
}>{`${name} is ${age}, has ${trait1} eyes and shoe size of ${trait2}.`}</Text>
</View>

{INPUTS.map(input => {
{INPUTS.map((input) => {
const isTraitsPart = input.stateFragment.includes('trait');

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

const onChangeHandler = text => {
const onChangeHandler = (text) => {
isTraitsPart
? this.setState(({traits: currentTraits}) => ({
traits: {
// $FlowFixMe
...currentTraits,
// $FlowFixMe
[input.stateFragment]: text,
},
}))
: this.setState({[input.stateFragment]: text});
: this.setState((state) => ({
// $FlowFixMe
...state,
// $FlowFixMe
[input.stateFragment]: text,
}));
};

return (
Expand Down
4 changes: 2 additions & 2 deletions example/ios/AsyncStorageExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -419,7 +419,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
12 changes: 6 additions & 6 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
source 'https://cdn.cocoapods.org/'
platform :ios, '9.0'
platform :ios, '12.0'
require_relative '../../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'AsyncStorageExample' do
# Pods for AsyncStorageExample
pod 'RNCAsyncStorage', :path => "../.."
pod 'FBLazyVector', :path => "../../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../../node_modules/react-native/Libraries/RCTRequired"
Expand All @@ -28,13 +26,15 @@ target 'AsyncStorageExample' do
pod 'React-jsi', :path => '../../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../../node_modules/react-native/ReactCommon"
pod 'ReactCommon/callinvoker', :path => "../../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga'
pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga', :modular_headers => true

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

pod 'RNCAsyncStorage', :path => "../.."

use_native_modules!
end
end
24 changes: 24 additions & 0 deletions example/macos/AsyncStorageExample-UITests.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'json'

package = JSON.parse(File.read(File.join('..', '..', 'package.json')))

Pod::Spec.new do |s|
s.name = 'AsyncStorageExample-UITests'
s.version = package['version']
s.author = { package['author']['name'] => package['author']['email'] }
s.license = package['license']
s.homepage = package['homepage']
s.source = { git: package['repository']['url'] }
s.summary = 'AsyncStorageExample UI tests'

s.ios.deployment_target = '12.0'
s.osx.deployment_target = '10.14'

s.dependency 'React'
s.dependency 'ReactTestApp-DevSupport'

s.framework = 'XCTest'
s.user_target_xcconfig = { 'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES' => '$(inherited)' }

s.source_files = 'AsyncStorageExample-macOSUITests/**/*.{m,swift}'
end
17 changes: 0 additions & 17 deletions example/macos/AsyncStorageExample-macOS/AppDelegate.h

This file was deleted.

Loading