Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9752d31

Browse files
airjp73Aaron Pettengillgaearon
authored
Document additionalHooks option (facebook#19005)
* Document `additionalHooks` option * Update README.md Co-authored-by: Aaron Pettengill <[email protected]> Co-authored-by: Dan Abramov <[email protected]>
1 parent b7ff888 commit 9752d31

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/eslint-plugin-react-hooks/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ If you want more fine-grained configuration, you can instead add a snippet like
4848
```
4949

5050

51+
## Advanced Configuration
52+
53+
`exhaustive-deps` can be configured to validate dependencies of custom Hooks with the `additionalHooks` option.
54+
This option accepts a regex to match the names of custom Hooks that have dependencies.
55+
56+
```js
57+
{
58+
"rules": {
59+
// ...
60+
"react-hooks/exhaustive-deps": ["warn", {
61+
"additionalHooks": "(useMyCustomHook|useMyOtherCustomHook)"
62+
}]
63+
}
64+
}
65+
```
66+
67+
We suggest to use this option **very sparingly, if at all**. Generally saying, we recommend most custom Hooks to not use the dependencies argument, and instead provide a higher-level API that is more focused around a specific use case.
68+
5169
## Valid and Invalid Examples
5270

5371
Please refer to the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html) documentation and the [Hooks FAQ](https://reactjs.org/docs/hooks-faq.html#what-exactly-do-the-lint-rules-enforce) to learn more about this rule.

0 commit comments

Comments
 (0)