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
Do you want to request a feature or report a bug?
Feature (to catch potential bugs)
What is the current behavior?
The react-hooks/rules-of-hooks ESLint rule catches uses of hooks in conditionals in components, but does not recognise an anonymous function wrapped in forwardRef as a component.
The following example breaks the rules of hooks, but isn't caught by the rule:
// This should failconstFancyButton=React.forwardRef((props,ref)=>{if(props.fancy){useCustomHook();}return<buttonref={ref}>{props.children}</button>;});
What is the expected behavior?
The above example should be caught by react-hooks/rules-of-hooks, and raise the "React Hook "useCustomHook" is called conditionally" error.
The text was updated successfully, but these errors were encountered:
* [eslint] Check forwardRef callbacks (#17220)
* [eslint] Make tests more realistic (#17220)
* [eslint] Check anonymous callback of React.memo for rules-of-hooks (#17220)
* [eslint] Add tests for callbacks not known to be components (#17220)
* [eslint] Correct comments and add another test (#17220)
Do you want to request a feature or report a bug?
Feature (to catch potential bugs)
What is the current behavior?
The react-hooks/rules-of-hooks ESLint rule catches uses of hooks in conditionals in components, but does not recognise an anonymous function wrapped in forwardRef as a component.
The following example breaks the rules of hooks, but isn't caught by the rule:
What is the expected behavior?
The above example should be caught by react-hooks/rules-of-hooks, and raise the "React Hook "useCustomHook" is called conditionally" error.
The text was updated successfully, but these errors were encountered: