Skip to content

Commit 34f8626

Browse files
committed
initialize store on all pages (no persist gate)
1 parent 0b93132 commit 34f8626

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/app/[locale]/[...slug]/page.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
import { type ReactNode, use, useEffect } from 'react';
66
import dynamic from 'next/dynamic';
77
import { PersistGate } from 'redux-persist/integration/react';
8-
import { persistStore } from 'redux-persist';
9-
import { store } from '../../store/store';
8+
import { persistor } from '../../store/store';
109
import { useAppDispatch } from '../../hooks';
1110
import { resetProfileErrors } from '../../store/profile-reducer';
1211

1312
const App = dynamic(async () => await import('../../App'), { ssr: false });
1413

15-
const persistor = persistStore(store);
16-
1714
interface PageProps {
1815
params: Promise<{
1916
locale: string;

src/app/store/store.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
persistReducer,
3+
persistStore,
34
FLUSH,
45
REHYDRATE,
56
PAUSE,
@@ -83,6 +84,11 @@ if (typeof window !== 'undefined' && (window as any).Cypress) {
8384

8485
sagaMiddleware.run(rootSaga);
8586

87+
// Create the persistor at the store level so rehydration and
88+
// state-persistence happen on every page load, not just on the
89+
// legacy catch-all route.
90+
export const persistor = persistStore(store);
91+
8692
export type RootState = ReturnType<typeof store.getState>;
8793
export type AppDispatch = typeof store.dispatch;
8894
export type AppThunk<ReturnType = void> = ThunkAction<

0 commit comments

Comments
 (0)