我只是想知道为什么在这个设置中,他将thunk放在数组中,并传播中间件参数,只是传递applyMiddleware (thunk)有什么区别。
import { createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import thunk from "redux-thunk";
import rootReducer from "./reducers";
const initialState = {};
const middleware = [thunk];
const store = createStore(
rootReducer,
initialState,
composeWithDevTools(applyMiddleware(...middleware))
);
export default store;发布于 2020-01-29 23:35:58
没有。这只是首选,如果你检查applyMiddleware签名,它可以直接使用5个中间件,或者如果你想要更多,你需要这个语法。
https://stackoverflow.com/questions/59968413
复制相似问题