From 7382e4e4ecc6a40142721f50b8dd1a52f8598882 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 10 Aug 2019 17:02:40 +0100 Subject: [PATCH] Link FAQ to testing recipes --- content/docs/hooks-faq.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content/docs/hooks-faq.md b/content/docs/hooks-faq.md index 1a2c4336a..dad506bfc 100644 --- a/content/docs/hooks-faq.md +++ b/content/docs/hooks-faq.md @@ -118,6 +118,10 @@ Importantly, custom Hooks give you the power to constrain React API if you'd lik From React's point of view, a component using Hooks is just a regular component. If your testing solution doesn't rely on React internals, testing components with Hooks shouldn't be different from how you normally test components. +>Note +> +>[Testing Recipes](/docs/testing-recipes.html) include many examples that you can copy and paste. + For example, let's say we have this counter component: ```js @@ -182,6 +186,8 @@ If you need to test a custom Hook, you can do so by creating a component in your To reduce the boilerplate, we recommend using [React Testing Library](https://testing-library.com/react) which is designed to encourage writing tests that use your components as the end users do. +For more information, check out [Testing Recipes](/docs/testing-recipes.html). + ### What exactly do the [lint rules](https://www.npmjs.com/package/eslint-plugin-react-hooks) enforce? {#what-exactly-do-the-lint-rules-enforce} We provide an [ESLint plugin](https://www.npmjs.com/package/eslint-plugin-react-hooks) that enforces [rules of Hooks](/docs/hooks-rules.html) to avoid bugs. It assumes that any function starting with "`use`" and a capital letter right after it is a Hook. We recognize this heuristic isn't perfect and there may be some false positives, but without an ecosystem-wide convention there is just no way to make Hooks work well -- and longer names will discourage people from either adopting Hooks or following the convention.