feat: add support for multiple arguments in renderHook()
What:
Add support for multiple arguments for function renderHook. Fixes #1350.
Why:
Hooks can take multiple arguments. The current implementation assumes a single argument (derived from render taking a single "props" for rendering components).
How:
Change renderHook to take a new array option "initialArgs". Option "initialProps" remains in place for backward compat. The options are mutually exclusive. The "rerender" function returned from "renderHooks" accepts multiple arguments as well.
Checklist:
- [x] Documentation added to the docs site testing-library-docs#1488
- [x] Tests
- [x] TypeScript definitions updated
- [x] Ready to be merged
Comments:
This is a redo of PR #1386 which lacks correct TS typings, tests for TS typings, documentation update, and seems to be abandoned.
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit b5f7249f924871ab7cfca8895e203aafa1a3ef08:
| Sandbox | Source |
|---|---|
| react-testing-library-examples | Configuration |