Skip to content

Commit 32b1e9b

Browse files
committed
fix: add location state
1 parent 5a2ff56 commit 32b1e9b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/router-core/src/link.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
DefaultAllRouteInfo,
55
RouteInfoByPath,
66
} from './routeInfo'
7-
import { Location } from './router'
7+
import { Location, LocationState } from './router'
88
import { Expand, NoInfer, PickAsRequired, PickRequired, Updater } from './utils'
99

1010
export type LinkInfo =
@@ -126,6 +126,8 @@ export type ToOptions<
126126
to?: ToPathOption<TAllRouteInfo, TFrom, TTo>
127127
// The new has string or a function to update it
128128
hash?: Updater<string>
129+
// State to pass to the history stack
130+
state?: LocationState
129131
// The source route path. This is automatically set when using route-level APIs, but for type-safe relative routing on the router itself, this is required
130132
from?: TFrom
131133
// // When using relative route paths, this option forces resolution from the current path, instead of the route API's path or `from` path

packages/router-core/src/router.ts

+2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export interface BuildNextOptions {
199199
params?: true | Updater<Record<string, any>>
200200
search?: true | Updater<unknown>
201201
hash?: true | Updater<string>
202+
state?: LocationState
202203
key?: string
203204
from?: string
204205
fromCurrent?: boolean
@@ -1258,6 +1259,7 @@ export function createRouter<
12581259
},
12591260
{
12601261
id,
1262+
...next.state,
12611263
},
12621264
)
12631265
} else {

0 commit comments

Comments
 (0)