Answer the question
In order to leave comments, you need to log in
Does it make sense to use withRouter in a construct like this: "withRouter(connect(mapStateToProps, mapDispatchToProps)(Component))"?
Studying the use of redux according to this example https://github.com/reactjs/redux/tree/master/examp...
I came across this expression "withRouter(connect(mapStateToProps, mapDispatchToProps)(ReactComponent))", while the result of this expression is passed to the Route component in the component property.
This code
Imported here
Question: "Isn't withRouter redundant in this case? After all, Route will pass history and match ?" "If not redundant, then why? What does it give?"
Answer the question
In order to leave comments, you need to log in
As far as I remember, Route will not pass data to a component if this component is wrapped in connect (or rather, in any hoc that uses a context other than the router).
I hope this problem will be fixed with the new Context API in the future.
// EDIT
Or there might be a problem if inside such a component (the component that we pass to Route, but it is wrapped in connect), Switch, Link and other components from react-router are used.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question