redux-persist: v5 - TypeError: In this environment the sources for assign MUST be an object.This error is a performance optimization and not spec compliant
Hey, umm… i’ve tried to implement redux persist for my project… After i followed your documentation on how to implement this module, there’s no problem.
but, when i tried to reload the app…Then it shows a blank white screen and shows warning TypeError: In this environment the sources for assign MUST be an object.This error is a performance optimization and not spec compliant
Then, i tried to change the config key from root to anything… like rootzzz. And it actually works. But then when i tried to change it again to root, it shows this blank screen again, with those warning
I don’t understand what’s going on… could you help me ?
this is my reducer list ./src/reducers/index.js
import {combineReducers} from 'redux';
import { persistCombineReducers } from 'redux-persist'
import storage from 'redux-persist/es/storage';
const config = {
key: 'root',
storage,
}
import { reducer as formReducer } from 'redux-form'
import AuthReducer from './AuthReducer';
import SideMenuReducer from './SideMenuReducer';
import SideMenuSelectReducer from './SideMenuSelectReducer';
import HomeDashReducer from './HomeDashReducer';
const reducers = {
form: formReducer,
auth : AuthReducer,
sidemenus: SideMenuReducer,
selectedMenuId : SideMenuSelectReducer,
menuHome : HomeDashReducer
}
export default persistCombineReducers(config, reducers);
and this is my code for ./App.js
import React, {Component} from 'react';
import {View} from 'react-native';
import expo from 'expo';
import {Provider} from 'react-redux';
import {createStore, applyMiddleware} from 'redux';
import ReduxThunk from 'redux-thunk';
import reducers from './src/reducers';
import Router from './src/Router';
import { persistStore } from 'redux-persist';
import { PersistGate } from 'redux-persist/es/integration/react';
function configureStore () {
// ...
let store = createStore(reducers, {}, applyMiddleware(ReduxThunk))
let persistor = persistStore(store)
return { persistor, store }
}
class App extends Component{
async componentWillMount(){
expo.Font.loadAsync({
'Roboto_medium': require('./assets/fonts/Roboto_medium.ttf'),
});
}
onBeforeLift = () => {
// take some action before the gate lifts
}
render(){
const { persistor, store } = configureStore();
return(
<Provider store={store}>
<PersistGate
loading={<View />}
onBeforeLift={this.onBeforeLift}
persistor={persistor}
>
<Router/>
</PersistGate>
</Provider>
);
}
}
export default App;
Is there anything wrong with my code ? its been 3 hours and i still have no clue
Thanks 😃
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 4
- Comments: 20 (5 by maintainers)
I was having the same issue. This maybe is because you have a state with a root key that the value is not an object, for example:
When trying to deserialized the above object will throw the error. Try to change to something like this
If you already have a persiste store with the error:
persistor.purge();afterconst persistor = persistStore(store);persistor.purge();@rt2zz can you validate this comment, thanks!
actually just cut redux-persist@5.3.0-rc which hopefully resolves this.
npm i redux-persist@nextto test@sun2rise I tried this line:
in order to reset my project but no success.
@ranggarifqi , @Cariosvertel … it all started working after a complete uninstall of the app and a new deploy with
react-native run-android. Maybe the store was sill there but in a v4 fashion and everything, that’s why you need to migrate or completely reinstall the app