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
It looks like, in v6, the only way to access the route state is via useLocation -- and, of course, useLocation mentions
Note: If you're using this it may mean you're doing some of your own
"routing" in your app, and we'd like to know what your use case is. We may
be able to provide something higher-level to better suit your needs.
So, i wrote this quick abstraction over useLocation to better manage state of a route:
My use case is to share a small bit of state among disparate components specific to a location, without having to clutter something like a redux store's state.
Are there any pitfalls to this approach? It seems to work fine. Could this be an addition to the library itself? Or as a recipe.
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
-
It looks like, in v6, the only way to access the route state is via
useLocation
-- and, of course,useLocation
mentionsSo, i wrote this quick abstraction over
useLocation
to better manage state of a route:My use case is to share a small bit of state among disparate components specific to a location, without having to clutter something like a redux store's state.
Are there any pitfalls to this approach? It seems to work fine. Could this be an addition to the library itself? Or as a recipe.
Beta Was this translation helpful? Give feedback.
All reactions