False negative of prop-types with stateless components
See original GitHub issueWhen a stateless component is created as a property of an object, prop-types
gives false negative:
🚫 reports “‘children’ is missing in props validation”:
Panel.Body = ({children}) => (
<div className='Panel-body'>
{children}
</div>
)
Panel.Body.propTypes = {
children: PropTypes.node
}
👌🏽 works fine:
const Body = ({children}) => (
<div className='Panel-body'>
{children}
</div>
)
Body.propTypes = {
children: PropTypes.node
}
Panel.Body = Body
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
False negative of prop-types with stateless components #735
When a stateless component is created as a property of an object, prop-types gives false negative: reports "'children' is missing in ...
Read more >React: PropTypes in stateless functional component
(The instance of a PropTypes object is lowercase, but the Class/Type is uppercase. The instance is List.propTypes .
Read more >children is missing in props validation - You.com - You.com
The rule is enforcing prop-types for all used props in your component (for documentation and debugging purpose), if you do not use the...
Read more >How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for ... FUNCTIONAL COMPONENTS */ function ReactComponent(props) ...
Read more >node_modules/eslint-plugin-react/CHANGELOG.md · master ...
no-unused-prop-types : Silence false positive on never type in TS (#2815 ... require-default-props : add option to ignore functional components (#2532 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Another example:
🚫 reports error:
Passes:
Cool, will do, thanks!