gpt4 book ai didi

javascript - Eslint 错误处理 React/prop-types

转载 作者:行者123 更新时间:2023-11-28 14:36:44 34 4
gpt4 key购买 nike

我正在使用 Airbnb javascript 标准来检查我的 React 应用程序,但遇到了一个错误,我不知道如何修复。这是我的应用程序中的第一个文件,所有其他组件将在此之后跟随

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
}

我的 this.props.children 抛出 eslint 错误 Prop 验证中缺少“children”(react/prop-types)

我不知道如何解决它,非常感谢任何帮助

提前致谢

最佳答案

您在 propTypes 中有一个拼写错误(您现在有 prototype),请尝试使用:

RootPage.propTypes={
children: PropTypes.node
}

关于javascript - Eslint 错误处理 React/prop-types,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49669924/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com