How can I dispatch from child components in React Redux?

前端 未结 2 796
逝去的感伤
逝去的感伤 2021-02-08 02:37

My server has code like this:

<

2条回答
  •  轮回少年
    2021-02-08 03:36

    There used to be advice to the effect to try to limit the components that you connect. See for example:

    https://github.com/reactjs/redux/issues/419

    https://github.com/reactjs/redux/issues/419#issuecomment-178850728

    Anyway, that's really more useful for delegating a slice of state to a component. You can do that if it makes sense for your situation, or if you don't want to pass down a callback that calls dispatch() you can pass the store or dispatch down the hierarchy if you want.

提交回复
热议问题