> For the complete documentation index, see [llms.txt](https://jonathan-zhang.gitbook.io/react-steppitguide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jonathan-zhang.gitbook.io/react-steppitguide/zhuang-tai-guan-li/redux_use/react-zi-zhi-thunk-zhong-jian-jian.md).

# Redux 自制thunk中间件

之前我们已经知道了thunk中间件是实现Redux异步的一种

```javascript
const thunk = ({dispatch,getState})=>next=>action=>{
  //如果是函数，执行一下
  if(typeof action==='function'){
     return action(dispatch,getState)
  }
  //
  return next(action)
}
export default thunk
```
