Skip to content

Commit

Permalink
docs(router): fix docs related to parsed state (#3194)
Browse files Browse the repository at this point in the history
* docs(router): fix docs related to parsed state

* docs(router): clarify usage of history state interface

* ci: apply automated fixes

* mention file where history state should be extended

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
ferretwithaberet and autofix-ci[bot] authored Jan 19, 2025
1 parent 18610d8 commit 80eab58
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/framework/react/api/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ title: Router API
- [`MatchRouteOptions Type`](./router/MatchRouteOptionsType.md)
- [`NavigateOptions Type`](./router/NavigateOptionsType.md)
- [`NotFoundError Type`](./router/NotFoundErrorType.md)
- [`ParsedHistoryState Type`](./router/ParsedHistoryStateType.md)
- [`ParsedLocation Type`](./router/ParsedLocationType.md)
- [`Redirect Type`](./router/RedirectType.md)
- [`Register Type`](./router/RegisterType.md)
Expand Down
13 changes: 13 additions & 0 deletions docs/framework/react/api/router/ParsedHistoryStateType.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
id: ParsedHistoryStateType
title: ParsedHistoryState type
---

The `ParsedHistoryState` type represents a parsed state object. Additionally to `HistoryState`, it contains the index and the unique key of the route.

```tsx
export type ParsedHistoryState = HistoryState & {
key?: string
__TSR_index: number
}
```
2 changes: 1 addition & 1 deletion docs/framework/react/api/router/ParsedLocationType.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface ParsedLocation {
pathname: string
search: TFullSearchSchema
searchStr: string
state: HistoryState
state: ParsedHistoryState
hash: string
maskedLocation?: ParsedLocation
unmaskOnReload?: boolean
Expand Down
10 changes: 8 additions & 2 deletions docs/framework/react/api/router/historyStateInterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ The `HistoryState` interface is an interface exported by the `history` package t
You can extend this interface to add additional properties to the state object across your application.

```tsx
interface HistoryState {
key: string // This is the unique ID for any given history entry
// src/main.tsx
declare module '@tanstack/react-router' {
// ...

interface HistoryState {
additionalRequiredProperty: number
additionalProperty?: string
}
}
```

0 comments on commit 80eab58

Please sign in to comment.