Does it make sense to use withRouter in this design: "withRouter(connect(mapStateToProps, mapDispatchToProps)(Component))"?

0 like 0 dislike
8 views
Studying the use of redux for this example https://github.com/reactjs/redux/tree/master/examp...
Came across this expression "withRouter(connect(mapStateToProps, mapDispatchToProps)(ReactComponent))", while the result of this expression is passed to the Route component.
This code
Imported here
The question is: "whether in this case withRouter excess? Because Route so will give history and match ?" "If not redundant, why? What gives?"
by | 8 views

1 Answer

0 like 0 dislike
As I recall, the Route will not pass data to a component if this component is wrapped in a connect (or any hoc which uses a context different from the router).
I hope that in future this problem with the new Context API corrected.

// EDIT

Either may be a problem, if inside a component (the component that pass the Route, but it is wrapped in a connect) used Switch, Link, and other components of react-router.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
asked Apr 27, 2019 by WarriorKodeK
0 like 0 dislike
2 answers
asked Apr 14, 2019 by Zewkin
110,608 questions
257,186 answers
0 comments
33,687 users