From a6e5f031d47d95ff912bc9c1ce9806ea6a811026 Mon Sep 17 00:00:00 2001 From: Tomas Zaicevas Date: Wed, 22 Jun 2022 22:44:25 +0200 Subject: [PATCH] docs: add a note on when not to use renderHook --- docs/react-testing-library/api.mdx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/react-testing-library/api.mdx b/docs/react-testing-library/api.mdx index 9e7cebcd9..62f58a100 100644 --- a/docs/react-testing-library/api.mdx +++ b/docs/react-testing-library/api.mdx @@ -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. +Alternatively, you should prefer `render` since a custom test component results in more readable and robust tests since the thing you want to test is not hidden behind an abstraction.