Skip to content

Commit 88aeec0

Browse files
louis-youngeps1lon
andauthored
docs: Add renderHook initialProps note when used in conjunction with wrapper (#1165)
Co-authored-by: Sebastian Silbermann <[email protected]>
1 parent e59ea97 commit 88aeec0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/react-testing-library/api.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,23 @@ test('returns logged in user', () => {
370370
})
371371
```
372372
373+
> NOTE: When using `renderHook` in conjunction with the `wrapper` and `initialProps` options, the `initialProps` are not passed to the `wrapper` component.
374+
> To provide props to the `wrapper` component, consider a solution like this:
375+
>
376+
> ```js
377+
> const createWrapper = (Wrapper, props) => {
378+
> return function CreatedWrapper({ children }) {
379+
> return <Wrapper {...props}>{children}</Wrapper>;
380+
> };
381+
> };
382+
>
383+
> ...
384+
>
385+
> {
386+
> wrapper: createWrapper(Wrapper, { value: 'foo' }),
387+
> }
388+
> ```
389+
373390
### `renderHook` Options `wrapper`
374391
375392
See [`wrapper` option for `render`](#wrapper)

0 commit comments

Comments
 (0)