Reactjs Redux thunk applyMiddleware

Reactjs Redux thunk applyMiddleware,reactjs,redux,redux-thunk,Reactjs,Redux,Redux Thunk,只是想知道为什么在这个设置中,他将thunk放在数组中,并通过传递applyMiddleware(thunk)来传播中间件参数之间的区别 没有。这只是首选项,如果您检查applyMiddleware签名,它最多可以直接占用5个中间件,或者如果您需要更多,则需要此语法 import { createStore, applyMiddleware } from "redux"; import { composeWithDevTools } from "redux-devtools-extension"

只是想知道为什么在这个设置中,他将thunk放在数组中,并通过传递applyMiddleware(thunk)来传播中间件参数之间的区别


没有。这只是首选项,如果您检查applyMiddleware签名,它最多可以直接占用5个中间件,或者如果您需要更多,则需要此语法

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;