美文网首页
🌟🌟🌟🌟:redux中间件 redux thunk

🌟🌟🌟🌟:redux中间件 redux thunk

作者: 达摩会武术 | 来源:发表于2019-03-26 15:27 被阅读0次

    1:不使用中间件,store接收的action只能是对象;有了中间件,action可以是一个函数。
    2:store接收一个action后,发现action不是对象而是函数,则会执行调用整个action函数。
    3.使用了redux thunk后分别在todolist.js中和actioncreator.js中调用了dispatch,todolist中的dispatch是将函数派发到store然后自动执行,然后通过actioncreator里面的dispatch派发真正的action给store(个人理解)。


    关于中间件:实际上就是对于dispatch方法的一个升级,不同的中间件对dispatch有不同的方法--ruedx thunk、redux logger 、redux-saga等等

    相关文章

      网友评论

          本文标题:🌟🌟🌟🌟:redux中间件 redux thunk

          本文链接:https://www.haomeiwen.com/subject/roswvqtx.html