https://github.com/peterpme/react-native-asyncstorage
📬 📫 🗄 Declarative AsyncStorage component for React Native
https://github.com/peterpme/react-native-asyncstorage
asyncstorage declarative react-native
Last synced: over 1 year ago
JSON representation
📬 📫 🗄 Declarative AsyncStorage component for React Native
- Host: GitHub
- URL: https://github.com/peterpme/react-native-asyncstorage
- Owner: peterpme
- Created: 2017-08-26T22:52:25.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-27T18:24:49.000Z (almost 9 years ago)
- Last Synced: 2024-10-13T11:13:38.297Z (over 1 year ago)
- Topics: asyncstorage, declarative, react-native
- Language: JavaScript
- Homepage:
- Size: 55.7 KB
- Stars: 31
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-native-asyncstorage
📬 📫 🗄 Declarative AsyncStorage component for React Native
[](https://badge.fury.io/js/react-native-asyncstorage)
- [Installation](#installation)
- [API](#api)
- [Usage Examples](#usage-examples)
## Installation
```zsh
yarn add react-native-asyncstorage
```
or
```zsh
npm install --save react-native-asyncstorage
```
## API
- [AsyncStorage.GetItem](#asyncstoragegetitem)
- [AsyncStorage.SetItem](#asyncstoragesetitem)
## AsyncStorage.GetItem
```js
itemKey: string
render: {
loading: boolean,
value: string | object,
error: string
}
```
## AsyncStorage.SetItem
```js
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
```jsx
{
if (loading) return
return (
Welcome to my app, ${value}
)
}}
/>
```
## Planned Updates
- multiGet & multiSet support for multiple keys
## Shoutout
Thanks to [@tkh44 for the idea and his localforage version](https://github.com/tkh44/react-localforage). He makes a lot of great shit, follow him on [Twitter](https://www.twitter.com/tkh44)