Exclude state setter from exhaustive-deps lint's dependencies check
See original GitHub issueThere should be a way to exclude the setter returned by useRecoilState (or the value returned by useRecoilSetState) from the lint’s dependencies check since they are known stable values:
const setValue = useRecoilSetState(...);
// or const [value, setValue] = useRecoilState(...);
React.useEffect(() => {
setValue(...)
}, []) // should not require setValue
It should work like the values returned by React.useState and React.useReducer, which I see currently is defined in the code of the lint:
I’m not sure where to file this issue actually. Should I file an issue in the react-hooks lint repo and propose a way to add exception for dependencies?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
reactjs - How do I configure eslint rules to ignore react-hooks ...
Just put the onChange function in your dependency array. Why is everybody's response to the tool, that React team at Facebook itself uses, ......
Read more >Understanding the React exhaustive-deps linting warning
You will see that lint gives you a couple of options: either adding count to the dependency array or removing the dependency array ......
Read more >Understanding the exhaustive-deps Eslint rule in React
The "react-hooks/exhaustive-deps" rule warns us when we have a missing dependency in an effect hook. To get rid of the warning, move the...
Read more >Hooks FAQ - React
How to test components that use Hooks? What exactly do the lint rules enforce? From Classes to Hooks. How do lifecycle methods correspond...
Read more >UseEffect Dependency Array : r/reactjs - Reddit
Either include it or remove the dependency array ... if you're a beginner) or add a eslint-disable-next-line react-hooks/exhaustive-deps .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s a supported pattern and can be common. atoms or selectors are often passed in via props or part of some dynamic config. Or, a different atom may be used from an
atomFamily()
orselectorFamily()
based on parameter values.Thanks! It should not be excluded then.