【发布时间】:2020-06-25 03:29:30
【问题描述】:
我有一个使用纯 css 的单选按钮,但它在第一次点击时不起作用,它只在第二次点击时起作用,不确定它是否与我的 react 道具有关:
const Radio = ({ id, name, value, checked, children }) => (
<div className="radioBtn">
<input type="radio" value={value} id={id} name={name} checked={checked} />
<label className={"radio"} htmlFor={id}>
<span className={"big"}>
<span className={"small"} />
</span>
<span>{children}</span>
</label>
</div>
);
【问题讨论】:
-
你读错了吗:
Warning: Failed prop type: You provided a 'checked' prop to a form field without an 'onChange' handler. This will render a read-only field. If the field should be mutable use 'defaultChecked'. Otherwise, set either 'onChange' or 'readOnly'?
标签: javascript css reactjs sass