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
Validation error for render prop #1919
Comments
Not really - functions that return JSX are components, according to our component detection. However, this seems like a case where the rule should be able to determine that's not a component. |
I had a slightly different situation: const React = require('react');
const OtherComponent = require('./OtherComponent');
function Component() {
return (
<OtherComponent
renderFoo={(foo) => <div>{foo.name}</div>}
renderBaz={({baz}) => <div>{baz.name}</div>}
renders={[{
foo: (foo) => <div>{foo.name}</div>,
baz: ({baz}) => <div>{baz.name}</div>
}]}
/>
);
}
module.exports = Component; I got a single error:
I think that there should be no errors at all. |
This is the same case where we should be able to determine that the function is not a component because it’s defined inline, in a jsx context, as an arrow function. |
I have a simple static functional component that defines a render prop:
and a corresponding default:
This triggers
react/prop-types
for function argumentshref
andchildren
claiming missing props validations. I'm am not aware of any way to validate arguments of a function. Is there anything I can do other than turn off the rule for each false positive?The text was updated successfully, but these errors were encountered: