Skip to content
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

Component rerender for optional URI params #234

Closed
oldwin opened this issue Mar 22, 2018 · 2 comments
Closed

Component rerender for optional URI params #234

oldwin opened this issue Mar 22, 2018 · 2 comments

Comments

@oldwin
Copy link

oldwin commented Mar 22, 2018

        <Route
          exact
          path="/path/:id/:additional?"
          component={userIsAuth(MyComponent)}
        />

Will always fire Component lifecycle as componentWillMount() for location changes and rerender it again and again.

  • /path/123
  • /path/123/test <-- remount
  • /path/123/test3 <-- remount

If I use just MyComponent without userIsAuth wrapper it works good without any remounting.

        <Route
          exact
          path="/cottages/:id/:optional?"
          component={MyComponent}
        />
const userIsAuth = connectedRouterRedirect({
  redirectPath: '/login',
  authenticatedSelector: ({ user }) => authenticatedSelector(user),
  wrapperDisplayName: 'UserIsAuthenticated',
  authenticatingSelector: ({ user }) => authenticatingSelector(user),
  AuthenticatingComponent: LoadingScreen,
  redirectQueryParamName: 'next',
});

Is it bug or any possibility to fix this behaviour?

@mjrussell
Copy link
Owner

mjrussell commented Mar 24, 2018

I think this is the same as #224. Take a look at https://mjrussell.github.io/redux-auth-wrapper/docs/Getting-Started/Overview.html#where-to-apply. You may need to apply the HOC (i.e. userIsAuth(MyComponent)) outside the Route and pass it in

@oldwin
Copy link
Author

oldwin commented Mar 31, 2018

@mjrussell thank you. Yes, it's the same issue like #224

For now workaround from @dtweedle fixed the problem
#224 (comment)

const myComponentWrapped = userIsAuth(MyComponent);

<Route
  exact
  path="/path/:id/:additional?"
  component={myComponentWrapped}
/>

Will watch another issue.

@oldwin oldwin closed this as completed Mar 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants