Closed
Description
Version
7.12.1 - 7.12.4 (haven't checked earlier versions)
Problem
Component where the return method calls a function instead of directly returning a jsx component will fail proptypes validation, even if the proptypes are properly declared.
Example
Broken
const SomeComponent = (props) => {
function renderComponent() {
return <div>{props.name}</div>
}
return renderComponent();
}
SomeComponent.propTypes = {
name: PropTypes.string
}
The following error will occur:
'name' is missing in props validation react/prop-types
Working Example
No errors occur in the following case
const SomeComponent = (props) => {
function renderName() {
return <div>{props.name}</div>
}
return (
<div>{renderName()}</div>
);
}
SomeComponent.propTypes = {
name: PropTypes.string
}