Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why the getFieldValue return value is not initialValue ? #539

Open
panpan-ren opened this issue Aug 18, 2022 · 0 comments
Open

why the getFieldValue return value is not initialValue ? #539

panpan-ren opened this issue Aug 18, 2022 · 0 comments

Comments

@panpan-ren
Copy link

panpan-ren commented Aug 18, 2022

I am a fan of ant-design.As the usage scenarios in business projects gradually increase, I find the getFieldValue function are not quite smart.The getFieldValue function will return undefined when render component, even though we set an initialValue props in a FormItem component.

I don't know why it's set like this,is there a reason this case?

Code example:

const App = () => {
  const [form] = Form.useForm();
  const name = form.getFieldValue("name");
  console.log(name); // undefined

  return (
    <Form {...layout} form={form} name="control-hooks">
      <Form.Item
        name="name"
        label="Name"
        initialValue="test"
        rules={[{ required: true }]}
      >
        <Input />
      </Form.Item>
    </Form>
  );
};
@panpan-ren panpan-ren changed the title why the getFieldValue return value is not initialValue why the getFieldValue return value is not initialValue ? Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant