我有一个无状态的React组件,如下所示:
const propTypes = exact({
fieldId: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
});
function Label({ fieldId, text }) {
return (
{text}
);
}
Label.propTypes = propTypes;
我正在使用与airbnb配置扩展的eslint.我的eslint看起来像这样:
{
"extends": "airbnb"
}
我的React代码抛出此错误:
error Form label must have associated control jsx-a11y/label-has-for
我已经清楚地设置了一个带有有效唯一id字符串的htmlFor属性(它与其他地方的输入上的id匹配).当然,这足以通过这条规则?

1611

被折叠的 条评论
为什么被折叠?



