You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/hooks/use-search-params-rn.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,19 +26,22 @@ type URLSearchParamsInit =
26
26
|URLSearchParams;
27
27
28
28
typeSetURLSearchParams= (
29
-
nextInit?:URLSearchParamsInit,
29
+
nextInit?:
30
+
|URLSearchParamsInit
31
+
| ((prev:URLSearchParams) =>URLSearchParamsInit),
30
32
navigateOpts?::NavigateOptions
31
33
) =>void;
32
34
33
35
interfaceNavigateOptions {
34
36
replace?:boolean;
35
37
state?:any;
38
+
resetScroll?:boolean;
36
39
}
37
40
```
38
41
39
42
</details>
40
43
41
-
The `useSearchParams` hook is used to read and modify the query string in the URL for the current location. Like React's own [`useState` hook](https://reactjs.org/docs/hooks-reference.html#usestate), `useSearchParams` returns an array of two values: the current location's [search params](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams) and a function that may be used to update them.
44
+
The `useSearchParams` hook is used to read and modify the query string in the URL for the current location. Like React's own [`useState` hook][usestate], `useSearchParams` returns an array of two values: the current location's [search params][searchparams] and a function that may be used to update them. Just as React's [`useState` hook][usestate], `setSearchParams` also supports [functional updates][functional-updates]. Therefore, you may provide a function that takes a `searchParams` and returns an updated version.
Copy file name to clipboardExpand all lines: docs/hooks/use-search-params.md
+14-3Lines changed: 14 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,14 +26,22 @@ type URLSearchParamsInit =
26
26
|URLSearchParams;
27
27
28
28
typeSetURLSearchParams= (
29
-
nextInit?:URLSearchParamsInit,
30
-
navigateOpts?:: { replace?:boolean; state?:any }
29
+
nextInit?:
30
+
|URLSearchParamsInit
31
+
| ((prev:URLSearchParams) =>URLSearchParamsInit),
32
+
navigateOpts?::NavigateOptions
31
33
) =>void;
34
+
35
+
interfaceNavigateOptions {
36
+
replace?:boolean;
37
+
state?:any;
38
+
resetScroll?:boolean;
39
+
}
32
40
```
33
41
34
42
</details>
35
43
36
-
The `useSearchParams` hook is used to read and modify the query string in the URL for the current location. Like React's own [`useState` hook](https://reactjs.org/docs/hooks-reference.html#usestate), `useSearchParams` returns an array of two values: the current location's [search params](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams) and a function that may be used to update them.
44
+
The `useSearchParams` hook is used to read and modify the query string in the URL for the current location. Like React's own [`useState` hook][usestate], `useSearchParams` returns an array of two values: the current location's [search params][searchparams] and a function that may be used to update them. Just as React's [`useState` hook][usestate], `setSearchParams` also supports [functional updates][functional-updates]. Therefore, you may provide a function that takes a `searchParams` and returns an updated version.
37
45
38
46
```tsx
39
47
import*asReactfrom"react";
@@ -66,5 +74,8 @@ function App() {
66
74
> of the URL. Also note that the second arg to `setSearchParams` is
0 commit comments