Browse Source

Link FAQ to testing recipes

main
Dan Abramov 6 years ago
committed by GitHub
parent
commit
7382e4e4ec
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      content/docs/hooks-faq.md

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

Loading…
Cancel
Save