-
Notifications
You must be signed in to change notification settings - Fork 729
docs: add a note on when not to use renderHook #1093
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,7 +328,10 @@ react supports `act`. It is recommended to use the import from | |
|
||
This is a convenience wrapper around `render` with a custom test component. The | ||
API emerged from a popular testing pattern and is mostly interesting for | ||
libraries publishing hooks. You should prefer `render` since a custom test | ||
libraries publishing hooks. | ||
|
||
Do not use `renderHook` when your hook is easy to test by just testing the components using it. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Do not use `renderHook` when your hook is easy to test by just testing the components using it.
Do not use `renderHook` when your hook can be easily tested by testing the components using it.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @zaicevas! |
||
Alternatively, you should prefer `render` since a custom test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is "alternatively" really needed here? I think we can remove it :) |
||
component results in more readable and robust tests since the thing you want to | ||
test is not hidden behind an abstraction. | ||
|
||
|