Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature proposal(eslint-react-hooks): Allow custom known stable values for exhaustive deps #19330

Closed
thien-do opened this issue Jul 13, 2020 · 1 comment

Comments

@thien-do
Copy link

As far as I know the list of known stable values for exhaustive-deps to exclude when checking dependencies are defined in the code of the lint:

// Next we'll define a few helpers that helps us
// tell if some values don't have to be declared as deps.
// Some are known to be stable based on Hook calls.
// const [state, setState] = useState() / React.useState()
// ^^^ true for this reference
// const [state, dispatch] = useReducer() / React.useReducer()
// ^^^ true for this reference
// const ref = useRef()
// ^^^ true for this reference
// False for everything else.
function isStableKnownHookValue(resolved) {

It would be great if this can be customized/appended (like the "additionalHooks" option) because some libraries like Recoil also have known stable values (e.g. the ones returned by "useSetRecoilState")

@bvaughn
Copy link
Contributor

bvaughn commented Jul 13, 2020

Looks like you're asking for the same thing as #19217 so let's move this discussion onto that issue 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants