[英]Using Redux-Saga in New Redux template react app
The new redux has a template built in for store and all the necessary thing to start a react redux app but it is using redux-thunk under the hood to make async calls.新的 redux 内置了一个用于存储的模板以及启动反应 redux 应用程序所需的所有东西,但它在后台使用 redux-thunk 进行异步调用。 It it not possible to replace this with redux-saga instead of thunk.
不可能用 redux-saga 而不是 thunk 替换它。
Redux Toolkit allows you to customize the list of middleware you're using using the middleware
option of configureStore
, same as if you're creating a Redux store with the base createStore
API. Redux Toolkit 允许您使用
configureStore
的middleware
选项自定义您正在使用的中间件列表,就像您使用基础createStore
ZDB974238714CA8DE634A7CE1D08 创建 Redux 存储一样。
You can completely replace the default list of pre-defined middleware by providing your own middleware
array, or call getDefaultMiddleware()
and add your own middleware to the array and use that.您可以通过提供自己的
middleware
数组来完全替换默认的预定义中间件列表,或者调用getDefaultMiddleware()
并将您自己的中间件添加到数组中并使用它。
So, my advice would be to do:所以,我的建议是:
const store = configureStore({
reducer: rootReducer,
middleware: getDefaultMiddleware().concat(sagaMiddleware)
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.