File tree 1 file changed +12
-0
lines changed
packages/docs/content/docs
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,18 @@ import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
128
128
}} >
129
129
```
130
130
131
+ When testing hooks that rely on nuqs' `useQueryState(s){ :ts } ` with React Testing Library's
132
+ [`renderHook{ :ts } `](https://testing-library.com/docs/react-testing-library/api/#renderhook) function,
133
+ you can use the `withNuqsTestingAdapter{ :ts } ` as a wrapper component passed into the
134
+ `renderHook{ :ts } ` call.
135
+
136
+ ```tsx
137
+ const { result } = renderHook(() => useMyNiceHook(), { wrapper : withNuqsTestingAdapter ({
138
+ searchParams: { q: ' hello-world' }
139
+ }) } )
140
+ ```
141
+
142
+
131
143
- `onUrlUpdate{ :ts } `, a function that will be called when the URL is updated
132
144
by the component. It receives an object with:
133
145
- the new search params as an instance of `URLSearchParams{ :ts } `
You can’t perform that action at this time.
0 commit comments