-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
React not rendering view when Link tag used inside redux #4756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
Is |
Anything that allows for your connected component to update when the location changes would work. Passing a |
What about the nested React.render(
<Router>
<Route path="/", render={({ match }) => <App matchUrl={match.url}>} />
</Router>
)
class App extends PureComponent {
render() {
const { matchUrl } = this.props;
return (
<div>
<Link to={matchUrl} >Home</Link>
<Link to={`${matchUrl}about`} >Home</Link>
<Route exact path={matchUrl} render={() => <h1>Home Component</h1>} />
<Route path={`${matchUrl}about`} render={({ location }) => <h1>About {location.url}</h1>} />
</div>
)
}
} In other words, does it mean I always have to pierce all the |
import { withRouter } from 'react-router-dom'
export default withRouter(connect(mapStateToProps)(Something)) this does the trick. https://reacttraining.com/react-router/web/guides/redux-integration |
withRouter() works, but you have to put it on the right component. For me that was the child of the |
After doing some researching, I found a similar issue regarding Redux's connect and {pure: false} workaround was fixed in react-router 3.0. I'm running react-router 4.0 (as part of react-router-dom) and still find this issue. reduxjs/react-redux#388
//bootstrap
var ConnectedAdminMain = connect( mapStateToProps, null, null)(Main);
// Main
// TestOne
Has <Link to="/foo">bar</Link>
Version
4.0.0
"react-redux": "^5.0.2",
"react-router-dom": "^4.0.0",
Test Case
Steps to reproduce
Expected Behavior
Actual Behavior
The text was updated successfully, but these errors were encountered: