-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: eslint-plugin-react-hooks
doesn't work inside export default () => { ... }
#27184
Comments
Hi @alexgorbatchev I don't know why but it seems like when you add a name to your function only then it's detect the conditional hook usage |
Hey there! I can address and Fix this issue. Please consider assigning this issue to me. |
Dupe of #14404 |
@rickhanlonii It seems that this issue has not been fixed yet, correct? To temporarily resolve this issue, we are modifying My question is: |
btw.....
function isObserverCallback(node) {
return !!(node.parent && node.parent.callee && isReactFunction(node.parent.callee, 'observer'));
}
function isInDefaultDeclaration(node) {
if ((node.type === 'ArrowFunctionExpression' || node.type === 'FunctionDeclaration') && node.parent.type ==='ExportDefaultDeclaration'){
return true
}
return false
}
// in create: function (context)
var isDefaultDeclaration = isInDefaultDeclaration(codePathNode);
// ....
if (isDirectlyInsideComponentOrHook || isDefaultDeclaration)
// ... I'm not sure if this modification is the correct approach, but it seems to be working well in our projects :D |
React version: 18
Steps To Reproduce
https://codesandbox.io/s/blissful-margulis-gljgjm?file=/src/App.js
The current behavior
Conditional hook usage isn't detected inside
export default () => { ... }
The expected behavior
Conditional hook usage should be detected inside
export default () => { ... }
The text was updated successfully, but these errors were encountered: