How the middleware in redux uses store as a parameter. For example, if thunk is in store, how can it take store as a parameter?

const thunk = store = > next = > action = >
typeof action = "function"?

action(store.dispatch, store.getState) :
next(action)

let todoApp = combineReducers (reducers) let store = createStore (
todoApp,
applyMiddleware (

thunk,

places))

Jul.18,2022

it is recommended to take a look at the Redux source code:

export default function applyMiddleware(...middlewares) {
  return (createStore) => (reducer, preloadedState, enhancer) => {
    const store = createStore(reducer, preloadedState, enhancer)
    let dispatch = store.dispatch
    let chain = []

    const middlewareAPI = {
      getState: store.getState,
      dispatch: (action) => dispatch(action)
    }
    chain = middlewares.map(middleware => middleware(middlewareAPI))
    dispatch = compose(...chain)(store.dispatch)

    return {
      ...store,
      dispatch
    }
  }
}
The middlewareAPI in the

applyMiddleware is the store generated from the original create Store, that is, the store in the thunk, and the return value of applyMiddleware is the store you finally declared to get, which is different.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3783f-2c0b4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3783f-2c0b4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?