`use-browser-location`
molefrog opened this issue Ā· comments
For V3, we want to ship a standalone hook wouter/use-browser-location
that will replace wouter/use-location
. The primary motivation for this is to remove confusion around import { useLocation } from "wouter"
and import useLocation from "wouter/use-location"
.
This hopefully will make it more clear that the standalone hook can be used without wouter, while the hook imported from "wouter"
will always rely on the current router's location.
I suggest that we don't just rename this module, but also work on some things the current version lacks:
- Ensure that we monkey-patch
pushState
only once, see #167 - Consider using
globalThis
when accessinglocation
(this needs to be researched) #344 - Allow to pass current
state
when performing navigation #102 - Breaking change: I think we can safely drop this
export const events
, since it looks more like an implementation detail - Breaking change: Use named exports only,
import { useBrowserLocation } from "wouter/use-browser-location"
- Migrate type specs
Additional: does the state
have to be returned from useBrowserLocation
? There is a PR #325 that adds it as a third argument, however I am not sure it's the right approach, since other hooks (like hash location or memory) will not implement it.
We could however allow location hooks to return the optional object that they can populate with whatever implemetation-specific parameters they need.
@jeetiss Can we close this now?