Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3: memory-location #355

Closed
molefrog opened this issue Oct 7, 2023 · 1 comment
Closed

V3: memory-location #355

molefrog opened this issue Oct 7, 2023 · 1 comment
Assignees
Labels
V3 Features that won't be released in v2, but planned for the next major release

Comments

@molefrog
Copy link
Owner

molefrog commented Oct 7, 2023

The second essential hook that will be included in the next release. Why: mostly for testing and maybe for environments that don't support location (Electron?).

Specs:

// no `use-` here since it is a high order hook
import { memoryLocation } from "wouter/memory-location"

// simple usage
const { hook } = memoryLocation({ path: "/initial-path" })
const [location, navigate] = hook()

// initial path is "/" by default
const { hook } = memoryLocation()

// must support `base` option for nested routing
const [location, navigate] = hook({ base: "/app" })

// standalone `navigate` method for navigating outside of components
const { navigate, hook } = memoryLocation()
navigate("/users")

// `static` option makes it immutable
const { hook } = memoryLocation({ static: true })
navigate("/users") // nothing happens

// `record` option for saving the navigation history
const { hook, navigate, history } = memoryLocation({ record: true })
navigate("/lol")
history // ["/lol", "/"]

After this hook is ready, we can migrate our tests to use memory location instead of relying on "test-utils"
More ideas?

@molefrog molefrog added the V3 Features that won't be released in v2, but planned for the next major release label Oct 7, 2023
@jeetiss jeetiss mentioned this issue Oct 9, 2023
5 tasks
@molefrog
Copy link
Owner Author

Closed via #358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V3 Features that won't be released in v2, but planned for the next major release
Projects
None yet
Development

No branches or pull requests

2 participants