https://github.com/netbeast/redux-persist-react-native-fs
Storage implementation of a redux-persist storage around react-native-fs
https://github.com/netbeast/redux-persist-react-native-fs
react-native react-native-fs redux redux-persist storage
Last synced: 8 months ago
JSON representation
Storage implementation of a redux-persist storage around react-native-fs
- Host: GitHub
- URL: https://github.com/netbeast/redux-persist-react-native-fs
- Owner: netbeast
- Created: 2017-05-23T11:25:37.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-05T09:50:56.000Z (over 8 years ago)
- Last Synced: 2024-10-29T08:04:10.055Z (over 1 year ago)
- Topics: react-native, react-native-fs, redux, redux-persist, storage
- Language: JavaScript
- Size: 3.91 KB
- Stars: 9
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# redux-persist-react-native-fs
[](https://www.npmjs.com/package/redux-persist-react-native-fs)
[](https://www.npmjs.com/package/redux-persist-react-native-fs)
React Native File System adapter for redux-persist storage.
[Learn more](https://github.com/rt2zz/redux-persist).
## Installation
1. Install [react-native-fs and link it](https://github.com/itinance/react-native-fs) to native android, ios, etc.
```
npm i --save react-native-fs
react-native link react-native-fs
```
2. Install this library
```
npm i --save redux-persist
```
## Usage
```javascript
import { NativeStorage } from 'redux-persist-react-native-fs'
/**
* For redux-persist
*/
const persistConfig = {
storage: NativeStorage,
// ...other config
}
export const persistor = persistStore(store, persistConfig)
/**
* Stand alone or for testing
*/
await NativeStorage.setItem('first', { test: 'common' })
await NativeStorage.setItem('nest', { of: { course: { is: 'nested' } }})
await NativeStorage.setItem('second', { of: { course: { is: 'nested' } }})
console.log({ keys: await NativeStorage.getAllKeys() })
NativeStorage.removeItem('second')
console.log({ tree: await NativeStorage.getFullTree() })
console.log({ first: await NativeStorage.getItem('first') })
```