简体   繁体   English

Eslint错误处理反应/属性类型

[英]Eslint error handling react/prop-types

I'm using the Airbnb javascript standards to lint my react app and i'm getting an error i'm not sure how to fix. 我正在使用Airbnb javascript标准来整理我的应用程序,但是出现错误,我不确定如何解决。 This is my first file in my application and all the other components will follow after this 这是我的应用程序中的第一个文件,此后所有其他组件

import React, { Component } from "react";
import PropTypes from 'prop-types';

export default class RootPage extends Component {
render() {
    return <div>{this.props.children}</div>;
    }
}

RootPage.prototype={
    children: PropTypes.node
}

My this.props.children is throwing eslint error 'children' is missing in props validation (react/prop-types) 我的this.props.children抛出eslint错误,道具验证中缺少'children'(反应/道具类型)

I have no idea how to fix it, any help is much appreciated 我不知道如何解决,非常感谢您的帮助

Thanks in advance 提前致谢

You have a typo in propTypes (you have now prototype ), try with: 您在propTypes有一个错字(您现在有了prototype ),请尝试:

RootPage.propTypes={
    children: PropTypes.node
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM