CopyPastor

Detecting plagiarism made easy.

Score: 1.7005435824394226; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2019-10-16
by Chaurasia

Original Post

Original - Posted on 2018-10-02
by Jason Hong



            
Present in both answers; Present only in the new answer; Present only in the old answer;

**local data and then sync** =
> import {AsyncStorage} from 'react-native';
Persisting data:
<!-- language: lang-js -->
_storeData = async () => { try { await AsyncStorage.setItem('@MySuperStore:key', 'I like to save it.'); } catch (error) { // Error saving data } };
<!-- end snippet -->
Fetching data:
<!-- language: lang-js -->
_retrieveData = async () => { try { const value = await AsyncStorage.getItem('TASKS'); if (value !== null) { // We have data!! console.log(value); } } catch (error) { // Error retrieving data } };
<!-- end snippet -->

I believe what you meant is to pass a value from one screen to another.
You can either use [AsyncStorage][1] to keep the data inside your memory, or pass the data through props [navigation][2]
AsyncStorage example:
Store Data:
_storeData = async () => { try { await AsyncStorage.setItem('@MySuperStore:key', 'I like to save it.'); } catch (error) { // Error saving data } }
Fetch Data:
_retrieveData = async () => { try { const value = await AsyncStorage.getItem('TASKS'); if (value !== null) { // We have data!! console.log(value); } } catch (error) { // Error retrieving data } }
Passing data through props navigation:
First class:
<Button onPress = { () => navigate("ScreenName", {name:'Jane'}) } />
Second class:
const {params} = this.props.navigation.state
[1]: https://facebook.github.io/react-native/docs/asyncstorage [2]: https://stackoverflow.com/a/47858644/8645857

        
Present in both answers; Present only in the new answer; Present only in the old answer;