Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
zaicevas wants to merge 1 commit into testing-library:main
base: main
Choose a base branch
Loading
from zaicevas:zaicevas-patch-1

Conversation

Copy link
Contributor

@zaicevas zaicevas commented Jun 22, 2022

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

@MatanBobi MatanBobi May 11, 2023

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

@MatanBobi MatanBobi May 11, 2023

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

@MatanBobi MatanBobi May 11, 2023

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 :)

eps1lon reacted with thumbs up emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@MatanBobi MatanBobi MatanBobi left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /