Skip to content
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

docs: add a note on when not to use renderHook #1093

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zaicevas
Copy link
Contributor

In https://github.com/testing-library/react-hooks-testing-library/blob/main/README.md there are two reasons when not to use react-hooks-testing-library:

  1. Your hook is defined alongside a component and is only used there 2. Your hook is easy to test by just testing the components using it

I think it still holds true and it would make sense to add this into renderHook docs. I've omitted the first point because it seems like the second point covers it. We could add both, though.

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.
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @zaicevas!
A minor suggestion here.

libraries publishing hooks.

Do not use `renderHook` when your hook is easy to test by just testing the components using it.
Alternatively, you should prefer `render` since a custom test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "alternatively" really needed here? I think we can remove it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants