react-testing-library icon indicating copy to clipboard operation
react-testing-library copied to clipboard

feat: add support for multiple arguments in renderHook()

Open danielrentz opened this issue 6 months ago • 1 comments

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:

Comments:

This is a redo of PR #1386 which lacks correct TS typings, tests for TS typings, documentation update, and seems to be abandoned.

danielrentz avatar Jun 20 '25 07:06 danielrentz

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

codesandbox-ci[bot] avatar Jun 20 '25 07:06 codesandbox-ci[bot]