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

useNavigate triggers unnecessarily rerenders components #8392

Closed
ayalpani opened this issue Nov 25, 2021 · 1 comment
Closed

useNavigate triggers unnecessarily rerenders components #8392

ayalpani opened this issue Nov 25, 2021 · 1 comment
Labels

Comments

@ayalpani
Copy link

ayalpani commented Nov 25, 2021

What is the new or updated feature that you are suggesting?

Hi!

I am using react-router-dom in v6. I need to navigate somewhere without having to use useNavigate.

Why should this feature be included?

As far as I understand, if I want to programatically change a route, I should use the useNavigate hook inside my component to get access to the navigate method. does not work in my use case.

I do render hundreds of components into my App and each of these components might trigger a route change and therefore all of them need to call useNavigate to get access to the navigate function. Now this is of course problematic as each route change triggers a rerender of those many components that use useNavigate.

Is there any way to work around the use of useNavigate but still trigger route changes?

Thanks a lot!

@ayalpani
Copy link
Author

Solved it by implementing this:

#8264 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant