0
votes

On the react-redux docs, Dan passes the clickHandler from the container component to the todolist, which then passes it down as props to the todo. At what level should a child component have his own connection to create a clickHandler through mapDispatchToProps?

For example, if the todo had it's own children of mini todos that necessitate a different type of click handler than the original todo, should this click handler be created all the way back in the container todolist and get passed down to todo and to the mini todo? OR should there be a separate container component for the mini todo which creates its own click handler through its own mapDispatchToProps?

This question is applicable to mapStateToProps too.

1

1 Answers

1
votes

According to the doc mapStateToProps is used if one the component wants to subscribe to Redux store updates. And if it is necessary to keep the child updated it should separate container component.

For best practices i will suggest this. (redux-duck method) Just look at the star of the repository . so many developers prefers this.