Skip to content

Commit

Permalink
Fix React Router not updating routes
Browse files Browse the repository at this point in the history
  • Loading branch information
kpuputti committed Apr 3, 2017
1 parent 5d32f57 commit 08952bc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 08952bc

Please sign in to comment.