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 quotcheckedquot value for a FormChecked react bootstrap elementStack Overflow