使用 Redux Toolkit 从商店中删除中间件

Remove middleware from store with Redux Toolkit

我有一个 ReactNative 应用程序,我正在尝试从我的中间件列表中删除中间件 'serializableStateInvariant'。页面 https://redux-toolkit.js.org/api/getDefaultMiddleware 缺少一些信息。

他们表示要配置商店:

const store = configureStore({
  reducer: rootReducer,
  middleware: [thunk, immutableStateInvariant]
})

但没有说明如何导入 thunk,或 immutableStateInvariant

如何导入它们,以便我可以将我的中间件设置为 [thunk, immutableStateInvariant],而无需 serializableStateInvariant

Thunk 不会重新导出,因此您需要省略可序列化检查以获得所需的结果。下面将保持 thunk/immutable 到位。

const store = configureStore({
  reducer: rootReducer,
  middleware: getDefaultMiddleware => getDefaultMiddleware({
    serializableCheck: false
  })