React Native Hooks Persist with Async Storage
yarn add react-native-hooks-persist
or
npm install react-native-hooks-persist
Name | Description |
---|---|
useStatePersist | Main hook persist method |
removeStatePersist | Remove an item from Store |
debugStatePersist | Debug all items on Store |
import {
useStatePersist,
removeStatePersist,
debugStatePersist,
} from 'react-native-hooks-persist';
const DB_NAME = 'globalStorage';
const FIELD_KEY = 'selectedColor';
const INITIAL_VALUE = 'Red';
const [color, setColor] = useStatePersist(DB_NAME, FIELD_KEY, INITIAL_VALUE);
<Text>{color.selectedColor} Selected</Text>
setColor(DB_NAME, FIELD_KEY, 'Blue');
setValue(DB_NAME, { [FIELD_KEY]: 4, [FIELD_KEY_COLOR]: 'Black' });
removeStatePersist(DB_NAME, FIELD_KEY);
debugStatePersist(DB_NAME);
-
yarn
ornpm install
-
react-native start
-
react-native run-ios
orreact-native run-android
- Clone this Repo
- Install dependencies
- Checkout develop branch
- Add your feature or fix
- Make sure your improvement works
- Open a pull request
Baked with Love ♥ from Cologne & Huelva
Thanks goes to these wonderful people (emoji key):
Yaxian 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!