Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Ant Design Form data in another Component

I've created a form using Ant design's Form.create() and i want to access it's field's values in another component. Using redux, i can do that using:

function mapStateToProps(state) {
  return {
    formStates: getFormValues('form')(state), 
  };
}

is there a way to do that for Ant design's Forms?

like image 459
Taha Moumen Avatar asked Nov 06 '19 15:11

Taha Moumen


People also ask

What is valuePropName?

valuePropName is the name of the prop of the child component that will contain the value. In most cases, components such as Input or Select use value as the prop for holding the value. However, certain components such as Checkbox or Switch use checked .

How do you display the first item by default in a dynamic antd form?

You have to click the "+ Add Field" button for the dynamic form to add and show the first field as shown here..

Is antd heavy?

antd is 348kB uncompressed. The entire app including antd, React and stupidly large lodash plus lots of other stuff is 350kB gzipped.


1 Answers

It can get the field values if the other component is inside Form.create().

Once the field has been registered with getFieldDecorator, you can access the value by props.form.getFieldValue('fieldName').

like image 105
Yu Chia Wu Avatar answered Sep 22 '22 06:09

Yu Chia Wu