By itself, a Redux store doesn’t know anything about async logic. It only knows how to synchronously dispatch actions, update the state by calling the root reducer function, and notify the UI that something has changed. Any asynchronicity has to happen outside the store. Redux middleware were designed to enable writing logic that has side effects. Also, since middleware form a pipeline around the real store.dispatch function, this also means that we could actually pass something that isn’t a plain action object to dispatch, as long as a middleware intercepts that value and doesn’t let it reach the reducers.
https://redux.js.org/tutorials/fundamentals/part-6-async-logic
something is sent from state -> UI gets the deposit -> clickevent gets to the event handler -> goes to the middleware -> send out an API request -> gets an API response back to the middleware -> action type goes back into the store
A middleware called Redux Thunk
With a plain basic Redux store, you can only do simple synchronous updates by dispatching an action. Middleware extends the store’s abilities, and lets you write async logic that interacts with the store.
“function”
“dispatch”
I’m only kind of understanding it, hopefully seeing it in action will be helpful to understanding how it works.