Implement Redux Persist for state persistence across page reloads

- Install redux-persist package
- Configure persistReducer with whitelist (offline, activities, children)
- Exclude network slice from persistence (should be fresh on reload)
- Add PersistGate to ReduxProvider with loading indicator
- Configure serializableCheck to ignore persist actions
- Store state now persists to localStorage automatically

This fixes the issue where app state was lost on page reload, improving UX.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-02 14:52:12 +00:00
parent 537e5d7823
commit 8c0981fa90
4 changed files with 2082 additions and 23 deletions

View File

@@ -2,8 +2,10 @@
import { useEffect, useRef } from 'react';
import { Provider } from 'react-redux';
import { store } from '@/store/store';
import { PersistGate } from 'redux-persist/integration/react';
import { store, persistor } from '@/store/store';
import { setupNetworkDetection } from '@/store/middleware/offlineMiddleware';
import { CircularProgress, Box } from '@mui/material';
export function ReduxProvider({ children }: { children: React.ReactNode }) {
const cleanupRef = useRef<(() => void) | null>(null);
@@ -20,5 +22,25 @@ export function ReduxProvider({ children }: { children: React.ReactNode }) {
};
}, []);
return <Provider store={store}>{children}</Provider>;
return (
<Provider store={store}>
<PersistGate
loading={
<Box
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
minHeight: '100vh'
}}
>
<CircularProgress />
</Box>
}
persistor={persistor}
>
{children}
</PersistGate>
</Provider>
);
}