Skip to content

Commit 41584bc

Browse files
authored
docs: Fix types related to history State (#8601)
1 parent 1d2c24e commit 41584bc

File tree

2 files changed

+24
-28
lines changed

2 files changed

+24
-28
lines changed

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@
2828
- turansky
2929
- underager
3030
- vijaypushkin
31+
- bhbs

docs/api.md

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ interface LinkProps extends TouchableHighlightProps {
310310
children?: React.ReactNode;
311311
onPress?(event: GestureResponderEvent): void;
312312
replace?: boolean;
313-
state?: State;
313+
state?: any;
314314
to: To;
315315
}
316316
```
@@ -475,7 +475,7 @@ declare function Navigate(props: NavigateProps): null;
475475
interface NavigateProps {
476476
to: To;
477477
replace?: boolean;
478-
state?: State;
478+
state?: any;
479479
}
480480
```
481481

@@ -831,7 +831,7 @@ The term "location" in React Router refers to [the `Location` interface](https:/
831831
>
832832
> The `history` package is React Router's only dependency and many of the
833833
> core types in React Router come directly from that library including
834-
> `Location`, `To`, `Path`, `State`, and others. You can read more about
834+
> `Location`, `To`, `Path`, and others. You can read more about
835835
> the history library in [its documentation](https://github.com/remix-run/history/tree/main/docs).
836836
837837
### `matchRoutes`
@@ -957,15 +957,12 @@ The `useHref` hook returns a URL that may be used to link to the given `to` loca
957957
<summary>Type declaration</summary>
958958

959959
```tsx
960-
declare function useLinkClickHandler<
961-
E extends Element = HTMLAnchorElement,
962-
S extends State = State
963-
>(
960+
declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(
964961
to: To,
965962
options?: {
966963
target?: React.HTMLAttributeAnchorTarget;
967964
replace?: boolean;
968-
state?: S;
965+
state?: any;
969966
}
970967
): (event: React.MouseEvent<E, MouseEvent>) => void;
971968
```
@@ -1025,13 +1022,11 @@ const Link = React.forwardRef(
10251022
<summary>Type declaration</summary>
10261023

10271024
```tsx
1028-
declare function useLinkPressHandler<
1029-
S extends State = State
1030-
>(
1025+
declare function useLinkPressHandler(
10311026
to: To,
10321027
options?: {
10331028
replace?: boolean;
1034-
state?: S;
1029+
state?: any;
10351030
}
10361031
): (event: GestureResponderEvent) => void;
10371032
```
@@ -1091,9 +1086,8 @@ The `useInRouterContext` hooks returns `true` if the component is being rendered
10911086
```tsx
10921087
declare function useLocation(): Location;
10931088

1094-
interface Location<S extends State = object | null>
1095-
extends Path {
1096-
state: S;
1089+
interface Location extends Path {
1090+
state: unknown;
10971091
key: Key;
10981092
}
10991093
```
@@ -1315,7 +1309,7 @@ function App() {
13151309
```tsx
13161310
declare function useSearchParams(
13171311
defaultInit?: URLSearchParamsInit
1318-
): [URLSearchParams, URLSearchParamsSetter];
1312+
): [URLSearchParams, SetURLSearchParams];
13191313

13201314
type ParamKeyValuePair = [string, string];
13211315

@@ -1325,12 +1319,10 @@ type URLSearchParamsInit =
13251319
| Record<string, string | string[]>
13261320
| URLSearchParams;
13271321

1328-
interface URLSearchParamsSetter {
1329-
(
1330-
nextInit: URLSearchParamsInit,
1331-
navigateOptions?: { replace?: boolean; state?: State }
1332-
): void;
1333-
}
1322+
type SetURLSearchParams = (
1323+
nextInit?: URLSearchParamsInit,
1324+
navigateOpts?: : { replace?: boolean; state?: any }
1325+
) => void;
13341326
```
13351327

13361328
</details>
@@ -1381,7 +1373,7 @@ function App() {
13811373
```tsx
13821374
declare function useSearchParams(
13831375
defaultInit?: URLSearchParamsInit
1384-
): [URLSearchParams, URLSearchParamsSetter];
1376+
): [URLSearchParams, SetURLSearchParams];
13851377

13861378
type ParamKeyValuePair = [string, string];
13871379

@@ -1391,11 +1383,14 @@ type URLSearchParamsInit =
13911383
| Record<string, string | string[]>
13921384
| URLSearchParams;
13931385

1394-
interface URLSearchParamsSetter {
1395-
(
1396-
nextInit: URLSearchParamsInit,
1397-
navigateOptions?: { replace?: boolean; state?: State }
1398-
): void;
1386+
type SetURLSearchParams = (
1387+
nextInit?: URLSearchParamsInit,
1388+
navigateOpts?: : NavigateOptions
1389+
) => void;
1390+
1391+
interface NavigateOptions {
1392+
replace?: boolean;
1393+
state?: any;
13991394
}
14001395
```
14011396

0 commit comments

Comments
 (0)