1import {configureStore} from '@reduxjs/toolkit';
2import storage from 'redux-persist/lib/storage'
3import {combineReducers} from "redux";
4import { persistReducer } from 'redux-persist'
5import thunk from 'redux-thunk'
6
7const reducers = combineReducers({
8 //...
9});
10
11const persistConfig = {
12 key: 'root',
13 storage
14};
15
16const persistedReducer = persistReducer(persistConfig, reducers);
17
18
19const store = configureStore({
20 reducer: persistedReducer,
21 devTools: process.env.NODE_ENV !== 'production',
22 middleware: [thunk]
23});
24
25export default store;
26
1import store from './app/store';
2import { PersistGate } from 'redux-persist/integration/react'
3import { persistStore } from 'redux-persist'
4
5let persistor = persistStore(store);
6
7 <Provider store={store}>
8 <PersistGate loading={null} persistor={persistor}>
9 <App/>
10 </PersistGate>
11 </Provider>,
12
1import {createAction, createReducer} from '@reduxjs/toolkit ;
2//Action
3const add = createAction('add');
4//Reducer
5const Reducer = createReducer(initialState= 0, (builder)=>{
6 builder.addCase(add, (state,action) => state + 1)
7})