-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
renderHook support for multiple parameters #1350
Comments
hey @danielrentz can I take this up? |
@amanreddy77 Sure! I did not start to prepare something by myself yet. |
@danielrentz - is anyone working on this? |
I hoped @amanreddy77 was... Otherwise I will try by myself. |
@danielrentz - happy with me to give it a go? |
@imevanc Sorry what do you mean exactly, do you want to start working on this, or do you want me to start? :) |
I'd like to start working on this, @danielrentz |
Nice, thanks! |
Describe the feature you'd like:
Testing hooks should support hooks with multiple parameters. Currently, the option "initialProps" of
renderHook
, and the "rerender" function it returns are supporting only a single parameter.Suggested implementation:
Obviously, for backwards compatibility, the option "initialProps" cannot be changed. Therefore, I suggest to add a new option "initialArgs" that is an array and renders the hook to be tested by spreading that array.
The function "rerender" returned from "renderHook" will take multiple parameters and forward them to the hook as well.
It should be an error (exception) to pass both options "initialProps" and "initialArgs" at the same time.
Describe alternatives you've considered:
As a workaround, I currently wrap my multi-arg hooks in a wrapper hook taking an array as "props", but that is cumbersome:
Teachability, Documentation, Adoption, Migration Strategy:
The text was updated successfully, but these errors were encountered: