📎 Add reactCompiler
option for useExhaustiveDependencies
#5293
Labels
A-Linter
Area: linter
D-React
Domain: React
good first issue
Good for newcomers
L-JavaScript
Language: JavaScript and super languages
S-Help-wanted
Status: you're familiar with the code base and want to help the project
S-Needs discussion
Status: needs a discussion to understand criteria
Description
useExhaustiveDependencies
currently reports a diagnostic when using functions that are not wrapped withuseCallback
as dependency: “[myFunc] changes on every re-render and should not be used as a hook dependency”.This diagnostic is not accurate for users of the React Compiler, since it automatically wraps such functions.
To resolve this, I agree with this comment that we should introduce an option for this.
Before starting work on this, I think we need to agree what to call the option and where to place it. I think having a single
reactCompiler
option makes sense, so that if we need other changes to accommodate the React Compiler users still only need to set one option. But that leaves the question whether it should be on theuseExhaustiveDependencies
rule, or if other React-related rules may also benefit from this, in which case we may prefer to move it up. Suggestions welcome!The text was updated successfully, but these errors were encountered: