Fix React Router not updating routes

https://github.com/ReactTraining/react-router/issues/4671
This commit is contained in:
Kimmo Puputti 2017-04-03 14:02:11 +03:00
parent 5d32f57696
commit 08952bc4fd

View file

@ -131,4 +131,10 @@ Routes.propTypes = {
const mapStateToProps = state => ({ isAuthenticated: state.Auth.isAuthenticated });
export default compose(connect(mapStateToProps), withRouter, withFlattenedRoutes)(Routes);
// Note: it is important that the withRouter HOC is **outside** the
// connect HOC, otherwise React Router won't rerender any Route
// components since connect implements a shouldComponentUpdate
// lifecycle hook.
//
// See: https://github.com/ReactTraining/react-router/issues/4671
export default compose(withRouter, connect(mapStateToProps), withFlattenedRoutes)(Routes);