How to solve: console.error: "redux-persist failed to create sync storage. falling back to "noop" storage
In redux-persist v6, you try changing as follows:
Old config V5 =>
import storage from 'redux-persist/lib/storage';
const persistConfig = {
//...
storage,
}
New config v6 =>
First add: yarn add @react-native-async-storage/async-storage
import AsyncStorage from '@react-native-async-storage/async-storage';
const persistConfig = {
//...
storage: AsyncStorage,
}
Before redux-persist
v6.0.0 you were using storage like this:
import storage from 'redux-persist/lib/storage';
What this uses in background is AsyncStorage
that was in react-native
core.
Since react-native
has deprecated AsyncStorage
and will remove it from react-native
core then the new version of redux-persist
has stopped using it and it seems a good decision.
You can do the same now but instead import AsyncStorage
from community version.
import AsyncStorage from '@react-native-community/async-storage';
And then use in in your config:
const persistConfig = {
storage: AsyncStorage,
//other configurations
};
Downgrading to redux-persist
v5 is not a stable solution since it uses AsyncStorage from core react-native
and react-native
will remove it completely in the upcoming versions.
Also I read in comments that you don't like AsyncStorage
, well as I explained redux-persist
has been using it as a storage so the only difference now is that you should get it from community version and not from react-native
core