Why does adding ref to the Input component of Antd design report an error?

in the modification function, get record and put it in form when you click on a record, and then click OK after modification. I want to get the value of each Input through this.refs.refName.value, but I find that as long as I add refs to the Input component of Antd, I will report an error:

this.refs.refName.valueinput

could you tell me how to solve this? Thank you ~

Mar.05,2021

get the value with the api included with antd form


Don't bother this.refs directly use the following API to get the value

form.getFieldsValue();

do not use refs to get value .
you already use the Form component.
so you can get the book name using getFieldValue or getFieldsValue .
eg: getFieldValue ('name') .
reference Form )


does not need to be obtained manually, and two-way data binding is implemented in antd.
there is demo on the official website

import { Form, Icon, Input, Button, Checkbox } from 'antd';
const FormItem = Form.Item;

class NormalLoginForm extends React.Component {
  handleSubmit = (e) => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        console.log('Received values of form: ', values); // values
      }
    });
  }
  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <Form onSubmit={this.handleSubmit} className="login-form">
        <FormItem>
          {getFieldDecorator('userName', {
            rules: [{ required: true, message: 'Please input your username!' }],
          })(
            <Input prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />} placeholder="Username" />
          )}
        </FormItem>
        <FormItem>
          {getFieldDecorator('password', {
            rules: [{ required: true, message: 'Please input your Password!' }],
          })(
            <Input prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} type="password" placeholder="Password" />
          )}
        </FormItem>
        <FormItem>
          {getFieldDecorator('remember', {
            valuePropName: 'checked',
            initialValue: true,
          })(
            <Checkbox>Remember me</Checkbox>
          )}
          <a className="login-form-forgot" href="">Forgot password</a>
          <Button type="primary" htmlType="submit" className="login-form-button">
            Log in
          </Button>
          Or <a href="">register now!</a>
        </FormItem>
      </Form>
    );
  }
}

to get a single value, you can use: getFieldValue ('fieldName') / / fieldName to indicate that you have used the value registered by getFieldDecorator. Your name/price/owner_id

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2272b-2ad94.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2272b-2ad94.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?