When should I add Redux to a React app?

前端 未结 7 1247
梦如初夏
梦如初夏 2020-12-04 06:31

I\'m currently learning React and I am trying to figure out how to use it with Redux for building a mobile app. I\'m kind of confused on how the two are related/usable toget

7条回答
  •  不知归路
    2020-12-04 06:57

    This is how redux works. A action is dispatched from any compoenent or view. Action MUST have "type" property and may be any property which holds information of action happened. The data passed in action, could be relevant to different reducer, so same object get passed to different reducer. Each reducer takes/ make-out its part/contribution to state. The output is then merged and new state get formed, and the component which must be subscribed for state change event gets notified.

    In above example, brown color has all 3 component RGB. Each reducer receives same brown color and they seperate out its contribution to the color.

提交回复
热议问题