Anu
Anu

Reputation: 1742

AsyncStorage : React Native

Save 'unique Id' as session variable in react native

Upvotes: 3

Views: 1140

Answers (2)

Syauqi Rahmat Sugara
Syauqi Rahmat Sugara

Reputation: 679

You can add the unique id using AsyncStorage like this :

import { AsyncStorage} from 'react-native';

AsyncStorage.setItem('Key Name', uniqueId)

And after that you can get from other component like this :

import { AsyncStorage} from 'react-native';

AsyncStorage.getItem('Key Name').then((value) => console.log(value))

For details you can read from the documentation. I hope this answer can help you.

Upvotes: 7

Hermenpreet Singh
Hermenpreet Singh

Reputation: 474

import { AsyncStorage} from 'react-native';
AsyncStorage.getItem('Key Name').then((value) => console.log(value))

we can get value from asyncstorage in any component of app.

number of another function are used like merge,remove etc.please see documentation

Upvotes: 3

Related Questions