我有一个工作商店,现在我需要实现redux状态持久性。
但是,在我结束这些教程之后,下面的要点以及createStore函数中的persistedReducer引发此错误:
TS2560:类型为'Reducer的值<{auth:只读<{access_token:字符串|空值;授权:字符串; isAuthenticated:布尔值; isLoggingIn:布尔值;用户:{权限:{批准:布尔值;违反:布尔值; };角色:“管理员” |空值; }; }>;对话框:只读<...>;通知:国家;用户:州; }&PersistPartial,AnyAction>'与'DeepPartial <{auth:Readonly <{access_token:string |空值;授权:字符串; isAuthenticated:布尔值; isLoggingIn:布尔值;用户:{权限:{批准:布尔值;违反:布尔值; };角色:“管理员” |空值; }; }>;对话框:只读<...>;通知:国家;用户:州; }>'。你是想打电话吗?
我认为它正在尝试交流。有人可以告诉我为什么会这样,因为我根本不理解该声明。
import { createBrowserHistory } from 'history'
import { applyMiddleware, createStore } from 'redux'
import { connectRouter, routerMiddleware } from 'connected-react-router'
import { composeWithDevTools } from 'redux-devtools-extension'
import rootReducer from './rootReducer'
import storage from 'redux-persist/lib/storage';
import { persistStore, persistReducer } from 'redux-persist';
const persistConfig = {
key: 'root',
storage: storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
export const history = createBrowserHistory()
export const store = createStore(
connectRouter(history)(rootReducer),
persistedReducer, <----error occurs here
composeWithDevTools(
applyMiddleware(
routerMiddleware(history)
)
)
)
export const persistor = persistStore(store)