Skip to content

hash router nesting and base #501

Open
@bonboru93

Description

@bonboru93

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>
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions