npm 开始显示错误 角色无线电不支持属性 aria-invalid .此角色隐式于元素输入



我在 npm 启动时面临以下错误src/components/Common/Radio/index.js 19:7 错误 角色无线电不支持属性 aria-invalid 。此角色隐含在元素输入 jsx-a11y/role-supports-aria-props 上

无线电/索引的代码.js

import React from 'react';
import PropTypes from 'prop-types';
import parse from 'html-react-parser';

const Radio = (props) => {
const {
id,
value,
checked,
handleChange,
text,
name,
invalid,
children,
disabled
} = props;
return (
<div className="form-item form-type-radio">
<input
type="radio"
id={id}
className="form-checkbox"
value={value}
checked={checked}
disabled={disabled || undefined}
name={name}
onChange={handleChange}
aria-invalid={!!invalid} />
<label className={`option ${invalid}`} htmlFor={id}>
{text ? parse(text) : null}
{children}
</label>
</div>
);
};

Radio.propTypes = {
id: PropTypes.string.isRequired,
value: PropTypes.string,
text: PropTypes.string,
checked: PropTypes.bool,
name: PropTypes.string,
handleChange: PropTypes.func,
invalid: PropTypes.string,
disabled: PropTypes.bool
};

export default Radio;

请提供帮助以修复错误。 您能否为单选按钮提供可接受的咏叹调属性。

aria-invalid 也可用于指示尚未填写必填字段

最新更新