Skip to content

feat: forward all render options through renderHook - #83

Closed
mahirhir wants to merge 1 commit into
testing-library:mainfrom
mahirhir:fix-renderhook-forward-options
Closed

feat: forward all render options through renderHook#83
mahirhir wants to merge 1 commit into
testing-library:mainfrom
mahirhir:fix-renderhook-forward-options

Conversation

@mahirhir

Copy link
Copy Markdown

renderHook only pulls wrapper out of its options and passes { wrapper } on to render, so the rest of the render options (container, baseElement, queries) get silently dropped. For example renderHook(cb, { container }) has no effect — the hook still mounts into a freshly created container under document.body.

@testing-library/react started out with the same shape and changed it in testing-library/react-testing-library#1118 to spread the remaining options straight through:

const { initialProps, ...renderOptions } = options
// ...
render(<TestComponent ... />, renderOptions)

This does the same thing here, so renderHook accepts the same render options as render.

I added a test that passes a custom container and checks the wrapper actually renders into it — without the change it fails (the marker ends up in the auto-created container instead). The rest of the suite stays green (105 tests).

Kept this to the runtime only and left the RenderHookOptions type alone, since #82 is already touching it.

@mahirhir

mahirhir commented Sep 5, 2026

Copy link
Copy Markdown
Author

Closing this myself: the repository has had no push in 184 days, so there is no one to review it right now. No hard feelings and no action needed. If the project picks up again and this is still wanted, I am happy to reopen or re-send it.

@mahirhir mahirhir closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant