switch is not getting checked when formitem value is true

I have an edit form . in that there switch inside form.Item so when that formitem is true it should be checked how to do it?
6 Replies
conscious-sapphire
conscious-sapphire3y ago
Hey @rehan1 You're using antd right?
absent-sapphire
absent-sapphireOP3y ago
yeah
conscious-sapphire
conscious-sapphire3y ago
Switch component is using checked prop instead of value
absent-sapphire
absent-sapphireOP3y ago
ok
conscious-sapphire
conscious-sapphire3y ago
In your Form.Item you need to define valuePropName="checked"
absent-sapphire
absent-sapphireOP3y ago
thanks @aliemirs <Form.Item name={title} valuePropName="checked"> <Switch onChange={onChange} checked={active} style={{ width: "60px" }} checkedChildren="yes" unCheckedChildren="No" /> </Form.Item> am using this way when its active i have to show some data

Did you find this page helpful?