npm.io
1.0.0 • Published 9 years ago

react-native-asyncstorage

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0
Stars
31

react-native-asyncstorage

Declarative AsyncStorage component for React Native

Installation

yarn add react-native-asyncstorage

or

npm install --save react-native-asyncstorage

API

  • AsyncStorage.GetItem
  • AsyncStorage.SaveItem

Usage Examples

Fetch apiToken from AsyncStorage before loading the rest of the app

<AsyncStorage.GetItem
  itemKey='apiToken'
  render={({ loading, value, error }) => {

    if (loading) return <AppLoading />

    return (
      <Provider store={store}>
        <AppWithNavigationState />
      </Provider>
    )

  }}
/>

Shoutout

Thanks to @tkh44 for the idea and his localforage version. He makes a lot of great shit, follow him on Twitter

Keywords