Introduction
Understand how to apply ESLint and the react-hooks plugin to enforce the essential rules of React Hooks. Learn why Hooks must be called only in React function components, always at the top level, and how to configure ESLint to catch rule violations during development.
We'll cover the following...
ESLint and Hooks
If we want to use Hooks and implement them in our applications, we need to follow a few rules that prevent us from running into unexpected errors or behaviors. ESLint and the eslint-plugin-react-hooks package, which has been developed by the React Team itself, helps us to
follow these rules and indicate when we might be breaching one. We advocate for the use of ESLint and recommend that you use it if you have not done so already.
To install the plugin, you can execute the following command on the command line:
npm install --save-dev eslint-plugin-react-hooks
Or, using Yarn:
yarn ...