wouter icon indicating copy to clipboard operation
wouter copied to clipboard

hash router nesting and base

Open bonboru93 opened this issue 1 year ago • 1 comments

As said in readme:

These can be used separately from the main module and have an interface similar to useState. These hooks don't support nesting, base path, route matching.

import { useBrowserLocation } from "wouter/use-browser-location" — allows to manipulate current location in the browser's address bar, a tiny wrapper around the History API. import { useHashLocation } from "wouter/use-hash-location" — similarly, gets location from the hash part of the address, i.e. the string after a #. import { memoryLocation } from "wouter/memory-location" — an in-memory location hook with history support, external navigation and immutable mode for testing. Note the module name because it is a high-order hook. See how memory location can be used in testing.

but according to my test, at least useHashLocation supports nested routing and base url.

const App = () => {
  return <Router hook={useHashLocation} base="/app">
    <Switch>
      <Route path="/login" component={Login} />
      <Route path="/register" component={Register} />
      <Route path="/ucenter" nest component={UCenter} />
    </Switch>
  </Router>
}

bonboru93 avatar Dec 22 '24 06:12 bonboru93

Hey, good point. This is incorrect, can you file a PR?

molefrog avatar Jan 25 '25 00:01 molefrog