Installation

The Recoil package lives in npm. To install the latest stable version, run the following command:

npm install recoil

Or if you're using yarn:

yarn add recoil

ESLint

If you are using eslint-plugin-react-hooks in your project. For example, with an eslint config like this:

// previous .eslint config
{
"plugins": [
"react-hooks"
],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}

It is recommended to add 'useRecoilCallback' to the list of additionalHooks. With this change, ESLint will warn when the dependencies passed to useRecoilCallback() are specified incorrectly and suggests a fix. The format of additionalHooks is a regex string.

// modified .eslint config
{
"plugins": [
"react-hooks"
],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": [
"warn", {
"additionalHooks": "useRecoilCallback"
}
]
}
}