question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting error redux-persist: rehydrate for "root" called after timeout

See original GitHub issue
redux-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:closed
  • Created 6 years ago
  • Reactions:65
  • Comments:98 (7 by maintainers)

github_iconTop GitHub Comments

56reactions
ssorallencommented, Nov 10, 2018

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):

const persistConfig: {
   ...
   timeout: 0, // The code base checks for falsy, so 0 disables
};

A complete solution for redux-persist would be to add a timeout component to PersistGate 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.

31reactions
hryercommented, Jul 12, 2019

try this

const persistConfig = { key: 'root', storage, timeout: null };

work for me

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found