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

What are the differences between RouteNode and Route? #449

Open
mahnunchik opened this issue Jan 31, 2020 · 5 comments
Open

What are the differences between RouteNode and Route? #449

mahnunchik opened this issue Jan 31, 2020 · 5 comments

Comments

@mahnunchik
Copy link

When should be used RouteNode and Route (useRoute/useRouteNode)?

@mahnunchik
Copy link
Author

Hi @troch

It would be nice to have some example use cases for each method.

image

It is not enough for newbies to understand correct way to use them.

@troch
Copy link
Member

troch commented Jan 31, 2020

Hello, the concept of route node is explained here: https://router5.js.org/introduction/core-concepts. It is an optimisation, you are quite good sticking with withRoute / Route / useRoute for now until you gain more familiarity with the library.

@mahnunchik
Copy link
Author

Thank you for the quick response.

Correct me please if I'm wrong. In term of hooks.

  • useRouter — the router instance, will fire re-render of the component if the instance of the router has changed.
  • useRoute — the router state, will fire re-render on each route change.

I don't understand the useRouteNode hook and when to use it.

@troch
Copy link
Member

troch commented Jan 31, 2020

  • useRouter: router instance won't change.
  • useRoute: correct
  • useRouteNode: will only change if the node declared if the node is affected by the route change (see doc linked).

@mahnunchik
Copy link
Author

Got it! Thank you!

I couldn't understand it because I've found examples with useRouteNode() or useRouteNode(''). Now I understand it is the root node. So method may be used with any node useRouteNode('users').

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