redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

PersistGate bootstrapped never set to true

Open ajfick opened this issue 4 years ago • 3 comments

I'm currently working a react-native project and having an issue that causes my app to give a white screen and never load on open. After some debugging, I've found that it appears to be because the bootstrapped state value in my PersistGate is never set to true despite it being possible for me to see that my state was rehydrated in the redux devtools. When I manually flip the bootstrapped state value in the PersistGate to true using my react-native devtools, the app immediately loads as expected.

One thing to note, it is necessary for me in this project, to be able to insert the filter values received from Firebase messaging (notifications) into the state before the rest of the app is rendered. Which is done by the constant declaration initialStore. I'm not sure if this is the correct way to handle this with redux-persist, or if it could be the cause of the bootstrapped state value not being set to true.

function StateWrapper({ filter }) {
  const initialStore = {...initialState, item: { ...initialState.item, filter: { ...initialState.item.filter, ...filter }}};

  const store = createStore(reducer, initialStore, __DEV__ && window.__REDUX_DEVTOOLS_EXTENSION__?  compose(applyMiddleware(thunk), reduxDevTools) : compose(applyMiddleware(thunk)));

  const persistor = persistStore(store);

  return (
    <Provider store={store}>
      <PersistGate loading={null} persistor={persistor}>
          <Navigation uriPrefix="lp://" />
      </PersistGate>
    </Provider>
  );
}

I'm not sure if this is a bug or an error on my part, but not rendering anything at all doesn't seem like the intended result to me.

ajfick avatar Mar 26 '20 04:03 ajfick

Same

using "redux-persist": "6.0.0"

MrOggy85 avatar Mar 31 '20 00:03 MrOggy85

Same here. But this was my own fault. I passed the rootReducer instead of the persistedReducer to the store. Hope this helps others.

marioklaver avatar May 12 '20 20:05 marioklaver

Same here, please have you found any solution to this... I am passing the persistedReducer to the store.

Below is my store; I am using redux toolkit configureStore

const store = configureStore({ reducer: persistedReducer, middleware: (getDefaultMiddleware) => getDefaultMiddleware({ serializableCheck: { ignoredActions: [FLUSH, REHYDRATE,PAUSE, PERSIST, PURGE, REGISTER] } }).concat([ unauthenticateMiddleware, apiSlice.middleware, ]), preloadedState: preloadedState, })

sokoya avatar Aug 22 '22 10:08 sokoya