All Projects â†’ peterpme â†’ React Native Asyncstorage

peterpme / React Native Asyncstorage

📬 📫 🗄 Declarative AsyncStorage component for React Native

Programming Languages

javascript
184084 projects - #8 most used programming language
declarative
70 projects

react-native-asyncstorage

📬 📫 🗄 Declarative AsyncStorage component for React Native

npm version

Installation

yarn add react-native-asyncstorage

or

npm install --save react-native-asyncstorage

API

AsyncStorage.GetItem

itemKey:  string
render: {
  loading: boolean,
  value: string | object,
  error: string
}

AsyncStorage.SetItem

itemKey: string
itemValue: string | object
render: {
  loading: boolean,
  value: string | object,
  error: string
}

Usage Examples

  • Fetch username from AsyncStorage 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>
    )
    
  }}
/>

Planned Updates

  • multiGet & multiSet support for multiple keys

Shoutout

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].