An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# react-native-asyncstorage

📬 📫 🗄 Declarative AsyncStorage component for React Native

[![npm version](https://badge.fury.io/js/react-native-asyncstorage.svg)](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)