feat: add render hook support for multiple arguments
What: Add render hook support for multiple arguments
Why: renderHook only supports a single argument via initialProps, making it hard to test hooks with multiple parameters. This PR introduces initialArgs to allow passing multiple arguments directly, improving flexibility and reducing workarounds.
How:
- Added initialArgs support → Spreads arguments into the hook.
- Updated rerender → Now accepts multiple parameters.
- Ensured backward compatibility → initialProps remains unchanged.
- Throws an error if both initialProps and initialArgs are used.
- Added tests & updated docs → Validates behavior and documents usage.
Issue: https://github.com/testing-library/react-testing-library/issues/1350
Checklist:
- [ ] Documentation added to the docs site
- [x] Tests
- [x] TypeScript definitions updated
- [x] Ready to be merged
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 42c12ac19cc7d984d5fcaaee133202861880bb42:
| Sandbox | Source |
|---|---|
| react-testing-library-examples | Configuration |
@eps1lon - awaiting your feedback 🧑💻
@danielrentz - anything to add ?
@Hardanish-Singh - just rebased, can you please thumb it again?
@imevanc @Hardanish-Singh the typings are still broken