You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
4:73 error React Hook useCallback has a missing dependency: 'props'.
Either include it or remove the dependency array. However, 'props' will change when any prop changes, so the preferred fix is to destructure the 'props' object outside of the useCallback call and refer to those specific props inside useCallback react-hooks/exhaustive-deps
The expected behavior
Error shouldn't be triggered since this code has a correct dependency of props.onChange
The text was updated successfully, but these errors were encountered:
This is expected behavior since props.onChange() has this inside onChange pointing to props. Which means that the effect should close over up-to-date values of props.
The warning includes the current recommendation: destructure onChange so that it is statically analyzable that you have a stable this.
I understand that it is very uncommon to use this as props but if you're not actually doing it you might as well destructure.
The change was introduced in #14993. Previous discussion: #18533
"eslint-plugin-react-hooks": "^4.1.2",
Steps To Reproduce
The current behavior
The expected behavior
Error shouldn't be triggered since this code has a correct dependency of
props.onChange
The text was updated successfully, but these errors were encountered: