我正在尝试在SSR应用程序中使用redux-persist 5.10.0实现redux 4.0.0,并且遇到一个问题,在该问题中,createStore()如果应用程序崩溃,我将无法正确提供预加载状态。
发生的情况是应用程序从服务器加载了初始状态,但是当应用程序尝试createStore()在客户端上预加载状态时,应用程序刷新并崩溃。我以为是因为我的preloadedState格式不正确?
但是我不确定,因为在控制台,UI,nada中没有收到任何错误消息。
这是一些相关的代码:
商店/index.js
export default function configureStore(preloadedState = {}) {
// This will store our enhancers for the store
const enhancers = [];
// Add thunk middleware
const middleware = [thunk];
// Apply middlware and enhancers
const composedEnhancers = compose(
applyMiddleware(...middleware),
...enhancers
);
// Set up persisted and combined reducers
const persistedReducer = persistReducer(persistConfig, rootReducer);
// Create the store with the persisted reducers and middleware/enhancers
const store = createStore(persistedReducer, preloadedState, composedEnhancers);
const …Run Code Online (Sandbox Code Playgroud) javascript reactjs redux server-side-rendering redux-persist