Hooks can only be called at the beginning of React function components or custom Hooks
Can we use Hooks in React class components?
No, it is not possible to use Hooks in React class components
What do we need to watch out for regarding the order of Hooks?
The order of Hooks should never change, as it is used to track the values of various Hooks
Can hooks be called inside conditions, loops, or nested functions?
No, Hooks cannot be called inside conditionals, loops, or nested functions, because that would change the order of Hooks
What is the naming convention for Hooks?
Hook function names should always start with a use prefix and then a name in CamelCase. For example: useSomeHookName.
How can we automatically enforce the rules of Hooks?
We can use eslint with eslint-plugin-react-hooks to enforce the rules of Hooks
What is the exhaustive dependencies rule?
The exhaustive dependencies rule ensures that in an Effect Hook all variables that are used are listed as dependencies via the second argument
How can we automatically fix linter warnings?
We can run the npm run lint -- --fix command to automatically fix linter warnings. Running this command will, for example, automatically enter all variables used in an Effect Hook as dependencies.