Search code examples
reactjsformscheckboxantd

How ```valuePropName``` Works?


I have a form with checkBox component. But when I submit the form whithout valuePropName . The checkBox value is undefined

<Form.Item name="remember" valuePropName="checked">
          <Checkbox>Remember me</Checkbox>
        </Form.Item>

I get the value when valuePropName is setted.

I'd like to know the why and how valuePropName whorks.


Solution

  • I think valuePropName specifies the name of the property that must be used as the value. For example, in the Checkbox component, valuePropName can be used to specify the name of the property that should be used as the value when the checkbox is checked. By default, this property is value, but you can specify a different property name by setting the valuePropName prop.