Skip to content

why useParams and useNavigate in react router does unnecessary re-renders? #10373

Closed Answered by sergiodxa
Flaain asked this question in Q&A
Discussion options

You must be logged in to vote

All RR and Remix hooks depends on the same React context

And while the navigate function is stable between renders meaning any effect depending on it won't trigger again, the way useContext works in React doesn't allow to pick only part of the state

This behavior cause that if the state is large any small change to it will cause a re render of any component accessing it

And when you navigate from one page to another there are many states inside this context changing like the navigation.status, the loader data, the route params, etc all any change there will cause a re render

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sergiodxa
Comment options

Answer selected by Flaain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants