admin管理员组文章数量:1291005
I want to create a Form.Check element conditionally based on a boolean that is set beforehand. I do it like the following:
... const [checked, setCheckState] = useState(false); ... return ( ... {some_value=== 'fixedval' && ( <Form.Group controlId="" className="conditional-checkbox"> <Form.Check type="checkbox" id=""> <Form.Check.Input type="checkbox" checked={checked} /*is there a way to only use changeCallback to set this value or do it is a must to go through a useState? */ onChange={(e) => { setCheckState(e.target.checked)}; changeCallback({ att_val: { value: e.target.checked, isInvalid: false, errorMsg: '', }, }); }} /> </Form.Check> ... ) ...
My question is: in the onChange
clause can I use both setCheckState
and changeCallback
?
Can I bypass using the setState
here and still be able to set checked={checked}
?
版权声明:本文标题:How to set the attribute "checked" value for a Form.Checked react bootstrap element - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741523975a2383356.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论