当我编译代码时,ESlint正在给我这个警告。我们正在使用AirBNB配置。
import React from 'react';
import { Link } from 'react-router-dom';
const ProfileInterestSkillButtons = ({
tags, title, user, member,
}) => {
return (
<div>
{title}
</div>
);
};
export default ProfileInterestSkillButtons;
您的组件正在使用它从其父组件接收的名为tags
的prop。
ESLint只是警告您在使用它的组件中为该prop定义类型检查。您可以使用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;
演讲:赌场
流程:https://reactjs.org/docs/typechecking-with-proptypes.html