Closed
Description
I hava a function which react/function-component-definition
is falsely reporting as a function component. This only seems to occur when null is returned at the end of a function.
My rule config is:
'react/function-component-definition': ['error', {
namedComponents: 'function-declaration',
unnamedComponents: 'arrow-function',
}],
function that triggers a false positive:
const selectAvatarByUserId = (state, id) => {
const user = selectUserById(state, id)
if (user) {
return user.attributes.image || `//api.adorable.io/avatars/${user.id}`
}
return null
}
Removing return null
or returning any other value fixes the error. I was able to get around this by reversing my if statement, but I'm still reporting this as a potential bug.