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

[Feature]: use useRoutes() render Router, re-render click link every time #8493

Closed
zsj1029 opened this issue Dec 16, 2021 · 2 comments
Closed
Labels

Comments

@zsj1029
Copy link

zsj1029 commented Dec 16, 2021

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

1、when i use <Routes> ,its normal ,layout render one time
https://stackblitz.com/edit/github-xy6mxl?file=src/App.tsx
page render one time

2、when i use useRoutes()
https://stackblitz.com/edit/github-eutnsg?file=src/App.tsx
when u click link, layout will re-render every time

Why should this feature be included?

I hope use useRoutes() performance like <Routes>

@zsj1029
Copy link
Author

zsj1029 commented Dec 16, 2021

Or what should I write code

@timdorr
Copy link
Member

timdorr commented Dec 16, 2021

This is expected. When you add the useRoutes hook, you're basically adding a subscription to the location on the page. When it changes, it triggers a re-render. You can optimize around this yourself, or use Routes to do this for you.

@timdorr timdorr closed this as completed Dec 16, 2021
brophdawg11 pushed a commit that referenced this issue Mar 27, 2024
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

2 participants