redux-persist#persistStore JavaScript Examples
The following examples show how to use
redux-persist#persistStore.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: store.js From react-14.01 with MIT License | 6 votes |
initStore =(preloadedState = {}) => {
const innitialStore = {};
const store = createStore(
persistReducer(persisitConfig, reducer),
innitialStore,
compose(applyMiddleware(routerMiddleware(history), logger, loadMiddleware, addMiddleware, deleteChatMiddleware, switchPageMiddleware, chatMiddleware, botMiddleware, apiMiddleware, thunk), devTools),
);
const persistor = persistStore(store);
return {store, persistor};
//return createStore(reducer, preloadedState, compose(applyMiddleware(logger, botMiddleware), devTools));
//return createStore(reducer, preloadedState, compose(applyMiddleware(routerMiddleware(history), logger, loadMiddleware, addMiddleware, switchPageMiddleware, chatMiddleware, botMiddleware), devTools));
}
Example #2
Source File: index.js From use-shopping-cart with MIT License | 6 votes |
export function CartProvider({ loading = null, children, ...props }) {
const store = React.useMemo(() => createShoppingCartStore(props), [props])
const persistor = persistStore(store)
return (
<Provider context={CartContext} store={store}>
<PersistGate
persistor={persistor}
children={(bootstrapped) => {
if (!bootstrapped) return loading
return children
}}
/>
</Provider>
)
}
Example #3
Source File: Rehydration.js From gDoctor with MIT License | 6 votes |
updateReducers = (store: Object) => {
const reducerVersion = ReduxPersist.reducerVersion
const startup = () => store.dispatch(StartupActions.startup())
// Check to ensure latest reducer version
AsyncStorage.getItem('reducerVersion').then((localVersion) => {
if (localVersion !== reducerVersion) {
if (DebugConfig.useReactotron) {
console.tron.display({
name: 'PURGE',
value: {
'Old Version:': localVersion,
'New Version:': reducerVersion
},
preview: 'Reducer Version Change Detected',
important: true
})
}
// Purge store
persistStore(store, null, startup).purge()
AsyncStorage.setItem('reducerVersion', reducerVersion)
} else {
persistStore(store, null, startup)
}
}).catch(() => {
persistStore(store, null, startup)
AsyncStorage.setItem('reducerVersion', reducerVersion)
})
}
Example #4
Source File: configure-store.js From sailplane-web with GNU General Public License v3.0 | 6 votes |
// if (__DEV__) {
// const logger = createLogger();
// middleware.push(logger);
// }
export default function configureStore(initialState) {
const store = compose(applyMiddleware(...middleware))(createStore)(
persistedReducer,
);
const persistor = persistStore(store);
return {store, persistor};
}
Example #5
Source File: index.js From full-stack-fastapi-react-postgres-boilerplate with MIT License | 6 votes |
configStore = (initialState = {}) => {
const store = createStore(reducer, initialState, composeEnhancer(applyMiddleware(...middleware)));
sagaMiddleware.run(rootSaga);
if (module.hot) {
module.hot.accept('reducers', () => {
store.replaceReducer(require('reducers/index').default);
});
}
return {
persistor: persistStore(store),
store,
};
}
Example #6
Source File: index.js From React-Nest-Admin with MIT License | 6 votes |
export default function configureStore() {
const middlewares = [ReduxThunk, routerMiddleware(history)];
const enhancers = [applyMiddleware(...middlewares)];
// use redux devtool, redux-thunk middleware
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
connectRouter(history)(persistedReducer),
composeEnhancers(...enhancers)
);
const persistor = persistStore(store);
return { store, persistor };
}
Example #7
Source File: routes.js From one-wallet with Apache License 2.0 | 6 votes |
Routes = () => {
const dispatch = useDispatch()
const [rehydrated, setRehydrated] = useState(false)
useEffect(() => {
const store = require('./state/store')
dispatch(globalActions.fetchPrice())
setInterval(() => {
if (!document.hidden) {
dispatch(globalActions.fetchPrice())
}
}, config.priceRefreshInterval)
persistStore(store.default, null, () => {
dispatch(walletActions.autoMigrateWallets())
dispatch(globalActions.migrate())
setRehydrated(true)
})
}, [dispatch])
if (!rehydrated) {
return (
<Layout>
<Layout.Content>
<Row type='flex' justify='center' align='middle' style={{ minHeight: '100vh' }}>
<Spin size='large' />
</Row>
</Layout.Content>
</Layout>
)
}
return (
<Switch>
<Route>
<LocalRoutes />
</Route>
</Switch>
)
}
Example #8
Source File: store.js From react-14.01 with MIT License | 6 votes |
initStore = (preloadedState = {}) => {
const store = createStore(
persistReducer(persistConfig, reducer),
preloadedState,
compose(
applyMiddleware(
routerMiddleware(history),
logger,
chatMiddleware,
botMiddleware,
apiMiddleware,
thunk
),
devTools
)
);
const persistor = persistStore(store);
return {
store,
persistor
};
}
Example #9
Source File: index.js From mediumx with MIT License | 6 votes |
export default function configureStore(preloadedState) {
const middlewares = [logger];
const middlewareEnhancer = applyMiddleware(...middlewares);
const syncStorageConfig = {
key: "syncStorage",
storage: syncStorage
};
const persistedReducer = persistReducer(syncStorageConfig, rootReducer);
let store = createStore(persistedReducer, preloadedState, middlewareEnhancer);
let persistor = persistStore(store);
return { store, persistor };
}
Example #10
Source File: index.js From react-03.03 with MIT License | 6 votes |
export function initStore (preloadedState = {}) {
const store = createStore(
persistReducer(persistConfig, reducer),
preloadedState,
composeEnhancers(
applyMiddleware(
ReduxThunk,
apiMiddleware,
routerMiddleware(history),
chatMiddleware,
botMiddleware
)
),
)
const persistor = persistStore(store)
return { store, persistor }
}
Example #11
Source File: store.js From Designer-Client with GNU General Public License v3.0 | 6 votes |
store = () => {
let store = createStore(
persistedReducer,
composeWithDevTools(
applyMiddleware(
axiosMiddleware(axiosClient),
thunkMiddleware,
loggerMiddleware
),
),
);
let persistor = persistStore(store);
return { store, persistor }
}
Example #12
Source File: store.js From react-firebase-admin with MIT License | 6 votes |
configureStore = initialState => {
const middlewares = [];
const composeEnhancers =
(process.env.NODE_ENV === 'development'
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
: null) || compose;
middlewares.push(applyMiddleware(thunk));
const store = createStore(
rootReducer,
initialState,
composeEnhancers(...middlewares)
);
store.dispatch(verifyAuth());
const persistor = persistStore(store);
return { store, persistor };
}
Example #13
Source File: Rehydration.js From Alfredo-Mobile with MIT License | 6 votes |
updateReducers = (store: Object) => {
const reducerVersion = ReduxPersist.reducerVersion
const startup = () => store.dispatch(StartupActions.startup())
// Check to ensure latest reducer version
AsyncStorage.getItem('reducerVersion').then((localVersion) => {
if (localVersion !== reducerVersion) {
if (DebugConfig.useReactotron) {
console.tron.display({
name: 'PURGE',
value: {
'Old Version:': localVersion,
'New Version:': reducerVersion
},
preview: 'Reducer Version Change Detected',
important: true
})
}
// Purge store
persistStore(store, null, startup).purge()
AsyncStorage.setItem('reducerVersion', reducerVersion)
} else {
persistStore(store, null, startup)
}
}).catch(() => {
persistStore(store, null, startup)
AsyncStorage.setItem('reducerVersion', reducerVersion)
})
}
Example #14
Source File: index.js From react-03.03 with MIT License | 6 votes |
export function initStore (preloadedState = {}) {
let store = createStore(
persistReducer(persistConfig,reducer),
preloadedState,
composeEnhancers(applyMiddleware(
ReduxThunk,
routerMiddleware(history),
botMiddleware,
chatMiddleware
))
)
let persistor = persistStore(store)
return { store, persistor }
}
Example #15
Source File: store.js From react-14.01 with MIT License | 6 votes |
function initStore() {
const innitialStore = {};
const store = createStore(
persistReducer(persistConfig, initReducers(history)),
innitialStore,
compose(
applyMiddleware(routerMiddleware(history), ...middlewares),
window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : () => {},
),
);
const persistor = persistStore(store);
return { store, persistor };
}
Example #16
Source File: store.js From react-tutorial with MIT License | 5 votes |
persistor = persistStore(store)
Example #17
Source File: store.js From react-14.01 with MIT License | 5 votes |
initStore = (preloadedState = {}) => {
const store = createStore(persistReducer(persistConfig, reducer), preloadedState, compose(applyMiddleware(routerMiddleware(history), chatMiddleware, botMiddleware, apiMiddleware, thunk), devTools));
const persistor = persistStore(store);
return {store, persistor};
}
Example #18
Source File: store.js From react-redux-jsonplaceholder with MIT License | 5 votes |
persistor = persistStore(store)
Example #19
Source File: index.js From electron-lightyearvpn with MIT License | 5 votes |
persistor = persistStore(store)
Example #20
Source File: index.js From real-frontend with GNU General Public License v3.0 | 5 votes |
persistor = persistStore(store)
Example #21
Source File: index.js From web with MIT License | 5 votes |
persistor = persistStore(store)
Example #22
Source File: store.js From CodeSignal-Practice_Solutions with MIT License | 5 votes |
persistor = persistStore(store)
Example #23
Source File: App.js From reactjs-functions with MIT License | 5 votes |
persistor = persistStore(store)
Example #24
Source File: index.js From discovery-mobile-ui with MIT License | 5 votes |
createStore = (authentication) => {
const { baseUrl, tokenResponse: { accessToken, idToken } } = authentication;
const fhirClient = new FhirClient(baseUrl, accessToken, idToken);
const epicMiddleware = createEpicMiddleware({
dependencies: {
fhirClient,
},
});
const { patientId } = fhirClient;
const rootReducer = combineReducers({
resources: flattenedResourcesReducer,
associations: associationsReducer,
activeCollectionId: activeCollectionIdReducer,
collections: collectionsReducer,
creatingCollection: isCreatingNewCollectionReducer,
});
const persistReducerConfig = {
version: '0.1.0',
key: `root-${patientId}`,
storage: AsyncStorage,
whitelist: ['activeCollectionId', 'collections', 'creatingCollection'],
};
const store = configureStore({
reducer: persistReducer(persistReducerConfig, rootReducer),
middleware: compose([
thunk,
epicMiddleware,
// routerMiddleware(history), // < e.g.: other middleware
]),
devTools: {
serialize: true, // See: https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize
},
});
epicMiddleware.run(rootEpic);
const callback = () => {
// callback function will be called after rehydration is finished.
};
const persistConfig = {
// manualPersist: true,
};
const persistor = persistStore(store, persistConfig, callback);
return {
store,
persistor,
};
}
Example #25
Source File: index.js From deno-seed with MIT License | 5 votes |
persistor = persistStore(store)
Example #26
Source File: index.js From tilli-web-app with GNU Affero General Public License v3.0 | 5 votes |
persistor = persistStore(store)
Example #27
Source File: configureStore.js From MediBuddy with MIT License | 5 votes |
persistor = persistStore(store, persistConfig, () => {
// console.log('Test', store.getState());
})
Example #28
Source File: index.jsx From ResoBin with MIT License | 5 votes |
persistor = persistStore(store)
Example #29
Source File: store.js From notence with MIT License | 5 votes |
persistor = persistStore(store)