Skip to content

Conversation

@jho406
Copy link
Collaborator

@jho406 jho406 commented Feb 14, 2025

navigateTo requires a page to exist in the pages slice in order to successfully navigate. You would have to create a page in the store before calling navigateTo. The most common scenario is creating a copy of the current page with new params before navigating. e.g, facet filters.

Its common enough that we add the ability to optimistically navigate. With these changes, you can provide a search hash that will get merged with the existing url query params. The page state is either copied over for history pushs or moved to a new pageKey for history replaces before navigating.

This also encourages folks to use the browser url to reflect application state, just like EmberJS instead of useState. For example:

resolves #135

const {
  navigateTo,
  pageKey,
  search
} = useContext(NavigationContext)

`navigateTo` requires a page to exist in the `pages` slice in order
to successfully navigate. You would have to create a page in the store
before calling `navigateTo`. The most common scenario is creating a copy
of the current page with new params before navigating. e.g, facet filters.

Its common enough that we add the ability to optimistically navigate. With
these changes, you can provide a `search` hash that will get merged with
the existing url query params. The page state is either copied over for
history `push`s or moved to a new pageKey for history `replace`s before
navigating.

This also encourages folks to use the browser url to reflect application
state, just like EmberJS instead of `useState`. For example:

resolves #135

```
const {
  navigateTo,
  pageKey,
  search
} = useContext(NavigationContext)
```
@jho406 jho406 force-pushed the add-optimistic-nav-options branch from 9c2d1a6 to d05d912 Compare February 14, 2025 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants