Skip to content

Commit

Permalink
docs: link to `NavigateOptions"
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyshlyaev177 committed Nov 24, 2024
1 parent 9d1a963 commit 83b477c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/urlstate/react-router/useUrlState/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A custom React hook that manages state and synchronizes it with URL search param

- `defaultState: object` - An object representing the default state values.
- `replace?: boolean` - Control will `setUrl` use `replace` or `push` methods on router, default replace=true, can override by `updateUrl(stateObj, { replace: false })`
- `options?: NavigateOptions` - `replace` arg and types from `NavigateOptions` of `react-router` type, same as options from `useNavigate`
- `options?: NavigateOptions` - `replace` arg and types from [`NavigateOptions`](https://api.reactrouter.com/v7/interfaces/react_router.NavigateOptions.html) of `react-router` type, same as options from `useNavigate`
- `useHistory` - Optionally can use window.history for navigation
- `preventScrollReset` - Option from react-router navigate

Expand Down Expand Up @@ -57,13 +57,13 @@ Updates both the state and the URL.
### Parameters:

- `value?: T | Partial<T> | (currState: T) => T` - Optional new state value or a function that receives the current state and returns the new state.
- `options?: NavigateOptions` - Optional options object from react-router's `NavigateOptions` type.
- `options?: NavigateOptions` - Optional options object from react-router's [`NavigateOptions`](https://api.reactrouter.com/v7/interfaces/react_router.NavigateOptions.html) type.

## `reset`

Updates both the state and the URL.

### Parameters:

- `options?: NavigateOptions` - Optional options object from react-router's `NavigateOptions` type.
- `options?: NavigateOptions` - Optional options object from react-router's [`NavigateOptions`](https://api.reactrouter.com/v7/interfaces/react_router.NavigateOptions.html) type.

4 changes: 1 addition & 3 deletions packages/urlstate/react-router/useUrlState/useUrlState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function useUrlState<T extends JSONCompatible>({
*
* @param {JSONCompatible<T>} [defaultState] Fallback (default) values for state
* @param {Object} params - Object with other parameters
* @param {NavigateOptions} params.NavigateOptions See type from `react-router-dom`
* @param {NavigateOptions} params.NavigateOptions See type from [`react-router-dom`](https://api.reactrouter.com/v7/interfaces/react_router.NavigateOptions.html)
* @param {boolean} params.replace replace URL or push, default `true`
* @param {boolean} params.useHistory use window.history for navigation, default `false`
* @param {boolean} params.preventScrollReset keep scroll position, default `true`
Expand Down Expand Up @@ -86,8 +86,6 @@ export function useUrlState<T extends JSONCompatible>(
* setState({ name: 'test' });
* // or
* setState(curr => ({ ...curr, name: 'test' }) );
* // can pass optional React-Router `NavigateOptions`
* setState(curr => ({ ...curr, name: 'test' }) );
* ```
*
* * Docs {@link https://github.com/asmyshlyaev177/state-in-url/tree/master/packages/urlstate/react-router/useUrlState#updatestate}
Expand Down

0 comments on commit 83b477c

Please sign in to comment.