使用 Redux Toolkit 从存储中删除中间件

Rya*_*ent 1 react-native react-redux redux-toolkit

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

他们表示要配置商店:

const store = configureStore({
  reducer: rootReducer,
  middleware: [thunk, immutableStateInvariant]
})
Run Code Online (Sandbox Code Playgroud)

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

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

Mat*_*ski 6

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

const store = configureStore({
  reducer: rootReducer,
  middleware: getDefaultMiddleware => getDefaultMiddleware({
    serializableCheck: false
  })
Run Code Online (Sandbox Code Playgroud)