-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
this.props.children throws error 'children' is missing in props validation #522
Comments
You can solve this simply by adding |
indeed, this seemed to do it |
Sure, that's one way. Better would be to explicitly denote in |
may I ask for a code snippet, please? thanks! |
function Foo() { return this.props.children; }
Foo.propTypes = { children: React.PropTypes.node.isRequired };
<Foo />; // ← error |
@ljharb muchas gracias, el senior! 🍻 since this project is ES6, under my class declaration simply:
|
For folks bumping into this now that static propTypes = {
children: PropTypes.node.isRequired
}; Hope that helps. |
@olivierlacan thanks for the tip! This is what worked for me, with eslint-plugin-react 7.11.1 import React, { Component } from 'react';
import PropTypes from 'prop-types';
class Layout extends Component {
state = {};
render() {
return(
<div>
{this.props.children}
</div>
);
}
}
Layout.propTypes = {
children: PropTypes.node.isRequired
};
export default Layout; |
I would like to use the reserved prop while not having to disable this rule. am I doing something wrong? Please advise!
{ this.props.children }
error 'children' is missing in props validation react/prop-types
The text was updated successfully, but these errors were encountered: