File tree Expand file tree Collapse file tree 4 files changed +20
-6
lines changed Expand file tree Collapse file tree 4 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { HelmetProvider } from 'react-helmet-async';
5
5
import { StylesContext } from './context' ;
6
6
import routes from './routes/routes.tsx' ;
7
7
import { useSelector } from 'react-redux' ;
8
-
8
+ import { RootState } from './redux/store' ;
9
9
import './App.css' ;
10
10
11
11
// color palettes: triadic #A1A7CB, #CBA1A7, #A7CBA1
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ import { NProgress } from '../../components';
38
38
import { PATH_LANDING } from '../../constants' ;
39
39
import { useSelector , useDispatch } from 'react-redux' ;
40
40
import { toggleTheme } from '../../redux/theme/themeSlice.ts' ;
41
-
41
+ import { RootState } from '../../redux/store.ts' ;
42
42
const { Content } = Layout ;
43
43
44
44
type AppLayoutProps = {
Original file line number Diff line number Diff line change 1
1
import { configureStore , combineReducers } from '@reduxjs/toolkit' ;
2
- import themeReducer from './theme/themeSlice' ;
2
+ import themeReducer , { ThemeState } from './theme/themeSlice' ;
3
3
import { persistReducer , persistStore , PersistConfig } from 'redux-persist' ;
4
4
import storage from 'redux-persist/lib/storage' ;
5
5
6
+ // Define the state shape
7
+ interface RootState {
8
+ theme : ThemeState ;
9
+ }
10
+
11
+ // Combine reducers
6
12
const rootReducer = combineReducers ( {
7
13
theme : themeReducer ,
8
14
} ) ;
9
15
10
- const persistConfig : PersistConfig < any > = {
16
+ // Persist config with RootState
17
+ const persistConfig : PersistConfig < RootState > = {
11
18
key : 'root' ,
12
19
storage,
13
20
version : 1 ,
14
21
} ;
15
22
16
23
const persistedReducer = persistReducer ( persistConfig , rootReducer ) ;
17
24
25
+ // Configure store with persisted reducer
18
26
export const store = configureStore ( {
19
27
reducer : persistedReducer ,
20
28
middleware : ( getDefaultMiddleware ) =>
21
- getDefaultMiddleware ( { serializableCheck : false } ) ,
29
+ getDefaultMiddleware ( {
30
+ serializableCheck : false ,
31
+ } ) ,
22
32
} ) ;
23
33
34
+ // Persistor
24
35
export const persistor = persistStore ( store ) ;
36
+
37
+ // Type for RootState
38
+ export type { RootState } ;
Original file line number Diff line number Diff line change 1
1
import { createSlice } from '@reduxjs/toolkit' ;
2
2
3
- interface ThemeState {
3
+ export interface ThemeState {
4
4
mytheme : string ;
5
5
}
6
6
You can’t perform that action at this time.
0 commit comments