@@ -18,10 +18,10 @@ route: '/reference/api'
18
18
## ` renderHook `
19
19
20
20
``` ts
21
- renderHook : (
21
+ function renderHook (
22
22
callback : (props ? : any ): any ,
23
23
options ? : RenderHookOptions
24
- ) => RenderHookResult
24
+ ): RenderHookResult
25
25
```
26
26
27
27
Renders a test component that will call the provided ` callback ` , including any hooks it calls , every
@@ -79,7 +79,7 @@ returned at the time.
79
79
### ` rerender `
80
80
81
81
` ` ` ts
82
- rerender : (newProps ? : any ) => void
82
+ function rerender (newProps?: any): void
83
83
` ` `
84
84
85
85
A function to rerender the test component, causing any hooks to be recalculated. If `newProps` are
@@ -88,7 +88,7 @@ passed, they will replace the `callback` function's `initialProps` for subsequen
88
88
### ` unmount `
89
89
90
90
` ` ` ts
91
- unmount : () => void
91
+ function unmount(): void
92
92
` ` `
93
93
94
94
A function to unmount the test component. This is commonly used to trigger cleanup effects for
@@ -97,7 +97,7 @@ A function to unmount the test component. This is commonly used to trigger clean
97
97
### ` hydrate `
98
98
99
99
` ` ` ts
100
- hydrate : () => void
100
+ function hydrate(): void
101
101
` ` `
102
102
103
103
> This is only used when using the ` server ` module . See [Rendering ](/ renderer ) for more information
@@ -122,7 +122,7 @@ exported from your chosen renderer. Although, they both work the same.
122
122
## ` cleanup `
123
123
124
124
` ` ` ts
125
- cleanup : () => Promise < void >
125
+ function cleanup(): Promise<void>
126
126
` ` `
127
127
128
128
Unmounts any rendered hooks rendered with ` renderHook ` , ensuring all effects have been flushed. Any
@@ -170,7 +170,7 @@ variable to `true` before importing `@testing-library/react-hooks` will also dis
170
170
## ` addCleanup `
171
171
172
172
` ` ` ts
173
- addCleanup : (callback : () => void | Promise <void >) => () => void
173
+ function addCleanup (callback: () => void | Promise<void>): (): void
174
174
` ` `
175
175
176
176
Add a callback to be called during [` cleanup ` ](/reference /api #cleanup ), returning a function to
@@ -187,7 +187,7 @@ be resolved before moving onto the next cleanup callback.
187
187
## `removeCleanup`
188
188
189
189
```ts
190
- removeCleanup : (callback : () => void | Promise <void >) => void
190
+ function removeCleanup (callback : () => void | Promise <void >): void
191
191
```
192
192
193
193
Removes a cleanup callback previously added with [`addCleanup`](/reference /api #addCleanup ). Once
@@ -201,7 +201,7 @@ removed, the provided callback will no longer execute as part of running
201
201
### `waitForNextUpdate`
202
202
203
203
```ts
204
- waitForNextUpdate : (options ? : { timeout? : number }) => Promise < void >
204
+ function waitForNextUpdate (options ? : { timeout? : number }): Promise <void >
205
205
```
206
206
207
207
Returns a `Promise` that resolves the next time the hook renders, commonly when state is updated as
@@ -213,12 +213,15 @@ The maximum amount of time in milliseconds (ms) to wait. By default, no timeout
213
213
214
214
### `waitFor`
215
215
216
- ``` js
217
- waitFor: (callback : () => boolean | void , options?: {
218
- interval?: number,
219
- timeout?: number,
220
- suppressErrors?: boolean
221
- }) => Promise < void >
216
+ ```ts
217
+ function waitFor(
218
+ callback : () => boolean | void ,
219
+ options ? : {
220
+ interval? : number
221
+ timeout? : number
222
+ suppressErrors? : boolean
223
+ }
224
+ ): Promise <void >
222
225
```
223
226
224
227
Returns a `Promise` that resolves if the provided callback executes without exception and returns a
@@ -243,12 +246,15 @@ rejected. By default, errors are suppressed for this utility.
243
246
244
247
### `waitForValueToChange`
245
248
246
- ``` js
247
- waitForValueToChange: (selector : () => any, options?: {
248
- interval?: number,
249
- timeout?: number,
250
- suppressErrors?: boolean
251
- }) => Promise < void >
249
+ ```ts
250
+ function waitForValueToChange(
251
+ selector : () => any ,
252
+ options ? : {
253
+ interval? : number
254
+ timeout? : number
255
+ suppressErrors? : boolean
256
+ }
257
+ ): Promise <void >
252
258
```
253
259
254
260
Returns a `Promise` that resolves if the value returned from the provided selector changes. It is
0 commit comments