Getting error redux-persist: rehydrate for "root" called after timeout
See original GitHub issueredux-persist: rehydrate for "root" called after timeout., Object {
"INITIALIZING": true,
"_persist": Object {
"rehydrated": true,
"version": -1,
},
"user": null,
}, undefined
- node_modules/redux-persist/lib/persistReducer.js:92:59 in _rehydrate
- ... 13 more stack frames from framework internals
I am using expo sdk version 25 My code is as below
reducers.js
export default (
state = {
INITIALIZING: true,
user: null
},
action
) => {
switch (action.type) {
default:
return state;
}
};
configureStore.js
import { createStore } from 'redux';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import rootReducer from './reducers';
const persistConfig = {
key: 'root',
storage
};
const persistedReducer = persistReducer(persistConfig, rootReducer);
export default () => {
let store = createStore(persistedReducer);
let persistor = persistStore(store);
return { store, persistor };
};
App.js
import React from 'react';
import { StyleSheet, Text, ActivityIndicator, View } from 'react-native';
import * as firebase from 'firebase';
import { PersistGate } from 'redux-persist/integration/react';
import { firebaseConfig } from './src/config';
import { Provider } from 'react-redux';
import configureStore from './src/configureStore';
import styled from 'styled-components';
// import Main from './src/screens/Main';
const { store, persistor } = configureStore();
firebase.initializeApp(firebaseConfig);
const StyledLoaderContainer = styled.View`
justify-content: center;
align-items: center;
margin-top: 100px;
`;
const Loading = () => (
<StyledLoaderContainer>
<ActivityIndicator />
<Text>Initializing...</Text>
</StyledLoaderContainer>
);
export default class App extends React.Component {
render() {
return (
<Provider store={store}>
<PersistGate loading={<Loading />} persistor={persistor}>
<View>
<Text>This is root</Text>
</View>
</PersistGate>
</Provider>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center'
}
});
Issue Analytics
- State:
- Created 6 years ago
- Reactions:65
- Comments:98 (7 by maintainers)
Top Results From Across the Web
Getting error while using ReactNative + Redux-persist V 5.10
This just when you are in debugger mode and this is mostly related to issue with setTimeout in React Native facebook/react-native#4470.
Read more >The Definitive Guide to Redux Persist - React Native Coach
The REHYDRATE action is dispatched by Redux Persist immediately after your persisted state is obtained from storage . If you return a new...
Read more >Rehydration Of Store Not Working With Reduxpersist In React ...
How to use Redux Persist in React Native The process of fetching a previously saved store is called rehydration The Problem Redux Persist...
Read more >console.error redux-persist rehydrate for root called after timeout
console.error redux-persist rehydrate for root called after timeout技术、学习、经验文章掘金开发者社区搜索结果。掘金是一个帮助开发者成长的社区,console.error ...
Read more >redux-persist-reborn - npm
If you want to avoid that the persistence starts immediately after calling persistStore , set the option manualPersist. Example: { manualPersist ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A workaround I’ve discovered for my own use: kill redux-persist’s
timeout
functionality. If the timeout hits, your store is rehydrated with the initial state and then persisted again to kill the state that is likely still loading.In your persist config, prevent the timeout setup (persistReducer.js#L88-99):
A complete solution for redux-persist would be to add a
timeout
component toPersistGate
that would render if your timeout is hit and stop the rehydration work. What it shouldn’t do is then rehydrate your store with initialState, which is the current functionality.try this
const persistConfig = { key: 'root', storage, timeout: null };
work for me