zheng hai 1 semana
pai
achega
c5fcea69df
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      21.react/高阶/project5/src/store/index.js

+ 4 - 3
21.react/高阶/project5/src/store/index.js

@@ -7,6 +7,7 @@ import userInfoSlice from './slices/userInfo';
 
 // 引入storage
 import storage from 'redux-persist/lib/storage'
+import { persistReducer, FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER } from 'redux-persist'
 
 // 合并reducer
 const rootReducer = combineReducers({
@@ -18,16 +19,16 @@ const rootReducer = combineReducers({
 const persistConfig = {
     key: 'redux-main',
     storage,
-    whiteList: ['user1'],
+    whitelist: ['user1'],
     // blackList:[]
 }
 
 // 将reducer传入持久化中 // 数据持久化 redux-persist
-const persistReducer = persistReducer(persistConfig, rootReducer)
+const persistedReducer = persistReducer(persistConfig, rootReducer)
 
 // 将切片集成到仓库上
 const store = configureStore({
-    reducer: persistReducer,
+    reducer: persistedReducer,
     middleware: getDefaultMiddleware => getDefaultMiddleware({
         serializableCheck: {
             ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]