Javascript 第5行:';标签';道具/道具类型中缺少
当我编译代码时,ESlint给了我这个警告。我们正在使用AirBNB配置Javascript 第5行:';标签';道具/道具类型中缺少,javascript,reactjs,webpack,eslint,eslint-config-airbnb,Javascript,Reactjs,Webpack,Eslint,Eslint Config Airbnb,当我编译代码时,ESlint给了我这个警告。我们正在使用AirBNB配置 import React from 'react'; import { Link } from 'react-router-dom'; const ProfileInterestSkillButtons = ({ tags, title, user, member, }) => { return ( <div> {title} &l
import React from 'react';
import { Link } from 'react-router-dom';
const ProfileInterestSkillButtons = ({
tags, title, user, member,
}) => {
return (
<div>
{title}
</div>
);
};
export default ProfileInterestSkillButtons;
从“React”导入React;
从'react router dom'导入{Link};
const ProfileInterestSkillButtons=({
标签、标题、用户、成员、,
}) => {
返回(
{title}
);
};
导出默认ProfileInterestSkillButtons;
您的组件正在使用从其父组件接收的名为标记的道具
ESLint只是警告您在使用该道具的组件中定义该道具的类型检查。您可以通过使用PropTypes
或使用flow
来实现这一点
使用PropType的简单示例如下:
... // other imports
import PropTypes from 'prop-types';
... // your component declaration
ProfileInterestSkillButtons.propTypes = {
tags: PropTypes.array.isRequired,
title: PropTypes.string.isRequired,
... // and more
};
export default ProfileInterestSkillButtons;
PropType:
流程:至少在此处粘贴包含“第5行”的代码?谢谢!刚刚添加了react组件的精简版本,所以,您没有进行任何验证,您想知道为什么会收到警告说您没有进行验证?