You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'useLocation' listens for route changes in a functional component. In some cases we don't need to do any listening at all, just do it once when the component is first loaded.
For example, using 'useOutlet' to implement a TAB feature, each tab corresponds to a route, and switching routes does not destroy the previous TAB. Using 'useLocation' in this case causes all open pages to listen for route changes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
'useLocation' listens for route changes in a functional component. In some cases we don't need to do any listening at all, just do it once when the component is first loaded.
For example, using 'useOutlet' to implement a TAB feature, each tab corresponds to a route, and switching routes does not destroy the previous TAB. Using 'useLocation' in this case causes all open pages to listen for route changes.
So far, I have come up with a good solution
By the feature of useState, useLocation is executed only once, which works fine.
Unfortunately react gives us multiple warnings
Is that why I need to officially provide a method to get the route pathname
Beta Was this translation helpful? Give feedback.
All reactions