Accessing persistor in unconnected part of app?
See original GitHub issueIn my app I call persistStore
when initializing store for the first time
// store.js
export default function configureStore(initialState = {}, history) {
...
const store = createStore(
createReducer(),
fromJS(initialState),
composeEnhancers(...enhancers) // includes autoRehydrate
);
const persistor = persistStore(store, { storage: localForage, whitelist: ['auth', 'support'] }, (a, b) => {
console.log('Redux-Persist loaded state');
});
...
return store;
}
// app.js
...
const initialState = {};
const store = configureStore(initialState, browserHistory);
const history = syncHistoryWithStore(browserHistory, store, {
selectLocationState: makeSelectLocationState(),
});
...
const render = (messages) => {
ReactDOM.render(
<Provider store={store}>
<LocaleProvider locale={enUS}>
<Router
history={history}
routes={createRoutes(store)}
render={
applyRouterMiddleware(useScroll())
}
/>
</LocaleProvider>
</Provider>,
document.getElementById('app')
);
};
Because I need REHYDRATE
to fire so I can get stored user auth info and skip login, etc.
If there is no user auth info (IE user is logged out) I would like to do something similar to https://github.com/rt2zz/redux-persist/issues/253 and call persistor.pause()
if the user has not checked “remember me” when they login.
However in the documentation I don’t see a clear way to access persistor
after it’s initially created. How can I do this? Does it require recreating my entire store using the current store as initial state? just so i can get another persistor
?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why is my website not loading anymore after using redux-persist
Your implementation seems to be wrong. Let's review them step by step: First, create a persistedReducer :
Read more >Persist state with Redux Persist using Redux Toolkit in React
Persisting state with Redux Persist. First, we'll add Redux Persist to our app with the following command: $ npm i redux-persist.
Read more >A Redux implementation with the new kid on the block: Flutter
Here, we will look into how to extend an app with a Redux store, Thunk future actions and the Redux Persistor.
Read more >System event codes and messages - TechDocs - Broadcom Inc.
Incidents folder The Incident Persister is unable to access the incident folder {0}. Check folder permissions. 1806. Response rule processing ...
Read more >Micro Focus Security ArcSight ESM Installation Guide
Installing Software ESM in Distributed Correlation Mode Using the. Configuration Wizard. 53. Installing ESM on the Persistor Node.
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
couple of options:
purgeStoredState
as followsI would recommend option 1 when possible
@FoxxMD me using
context
is kind of shameful too, but, basically I declaredstore
as acontextType
on aPurge
class component: