Answer a question

Currently I have disabled the serializableCheck in my store.js and it works, however I'd prefer if I could only set it to false for one reducer in particular, and keep it set to true for all the rest.

export const store = configureStore({
        reducer: {
            app: appReducer,
            settings: settingsReducer,
            admin: adminReducer,
            popout: popoutReducer,
        },
        middleware: getDefaultMiddleware({
            serializableCheck: false,
        }),
    });

I'm aware disabling this check can cause issues in the future, I only have one reducer where I want this check to be disabled.

Answers

Per the docs at https://redux-toolkit.js.org/api/serializabilityMiddleware , you should be able to use the ignoredPaths option to provide a keypath string to ignore in the state:

configureStore({
  reducer: rootReducer,
  middleware: (getDefaultMiddleware) => getDefaultMiddleware({
    serializableCheck: {
      ignoredPaths: ['someSlice.nested.field']
    }
  })
})

That said, I'd still recommend finding ways to store serializable values in the state instead.

Logo

React社区为您提供最前沿的新闻资讯和知识内容

更多推荐