Skip to content

Commit

Permalink
add navigate docs for state
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Kye authored and Tim Kye committed Mar 23, 2021
1 parent 9e8a93d commit a3d3edf
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion docs/api/navigate.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export function navigate(url: string, replace?: boolean): void
export function navigate(
url: string,
query?: QueryParam | URLSearchParams,
replace?: boolean
replace?: boolean,
state?: unknown
): void
```

Expand Down Expand Up @@ -56,3 +57,16 @@ export async function createUser () {
navigate(`/users/${user.id}` { ref: 'create page' })
}
```

## Navigating with History State

By default the `state` is `null`. You can control the `state` passed to `history.pushState | history.replaceState` using the fourth parameter

```jsx
import { navigate } from 'raviger'
export async function createUser () {
let user = await createUser()
navigate(`/users/${user.id}`, undefined, undefined, { user: user })
}
```

0 comments on commit a3d3edf

Please sign in to comment.