-
-
Notifications
You must be signed in to change notification settings - Fork 890
Description
Description
useExhaustiveDependencies currently reports a diagnostic when using functions that are not wrapped with useCallback 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 the useExhaustiveDependencies rule, or if other React-related rules may also benefit from this, in which case we may prefer to move it up. Suggestions welcome!