📬 📫 🗄 Declarative AsyncStorage component for React Native
yarn add react-native-asyncstorage
or
npm install --save react-native-asyncstorage
itemKey: string
render: {
loading: boolean,
value: string | object,
error: string
}
itemKey: string
itemValue: string | object
render: {
loading: boolean,
value: string | object,
error: string
}
- Fetch
username
fromAsyncStorage
before rendering the rest of your app
<AsyncStorage.GetItem
itemKey='username'
render={({ loading, value, error }) => {
if (loading) return <AppLoading />
return (
<View style={styles.container}>
<Text>Welcome to my app, ${value}</Text>
</View>
)
}}
/>
- multiGet & multiSet support for multiple keys
Thanks to @tkh44 for the idea and his localforage version. He makes a lot of great shit, follow him on Twitter