Storage adaptor to use react-native-fetch-blob with redux-persist, by implementing the needed methods: setItem
, getItem
, removeItem
and getAllKeys
This storage can be used on Android to prevent issues with the storage limitations in the RN AsyncStorage implementation. (See redux-persist#199, redux-persist#284)
yarn add redux-persist-filesystem-storage
Then, as react-native-fetch-blob is a dependency of this project, we need to ensure its linked with
react-native link react-native-fetch-blob
(or check their docs).
import FilesystemStorage from 'redux-persist-filesystem-storage'
import { persistStore, autoRehydrate } from 'redux-persist'
const store = createStore(reducer, undefined, autoRehydrate())
persistStore(
store,
{
storage: FilesystemStorage,
},
)
import RNFetchBlob from 'react-native-fetch-blob'
import FilesystemStorage from 'redux-persist-filesystem-storage'
import { persistStore, autoRehydrate } from 'redux-persist'
const store = createStore(reducer, undefined, autoRehydrate())
persistStore(
store,
{
storage: FilesystemStorage.config(
{
storagePath: `${RNFetchBlob.fs.dirs.DocumentDir}/persistStore`,
},
},
)
)