Principles and Rules of Hooks
npm install --save-dev eslint-plugin-react-hooksyarn add --dev eslint-plugin-react-hooks{
"plugins": [
// ...
"react-hooks"
],
"rules": {
// ...
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}The rules of Hooks
Hooks can only be used in React function components
Hooks are only allowed to be used on the highest layer inside of the function component
Last updated