Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there no onchange for `<Input>` in Ant design

I know I must be missing something very simple but why is there no onChange for <Input> tag of Ant design?

I would like the update the value of an input.

I assumed there was something like an onChange, since I was able to use onChange with DatePicker and handleChange DropDown; but I guess I assumed wrong

When I looked at the docs, there is a onPressEnter callback, but that is not really going to help me.

I tried the following:

   <Input
     placeholder="Flight name"
     size="large"
     value={this.state.someVal}
   />

But this just gave me an input that I could not type in.

So to reiterate:

  1. Why is there no onChange for <Input> tag of Ant design?
  2. More importantly, how do I get the value of the <Input> tag?

Thanks.

like image 555
user2517182 Avatar asked Sep 18 '18 04:09

user2517182


People also ask

How do you clear form data after submit in ANTD?

the simplest way to reset the entire form you use resetForm().

Who uses ANTD?

Created by Alibaba, the Ant design system is used by several big names like Alibaba (of course), Tencent, Baidu, and more. It has fast become the most used React UI library. Previously Material-UI was the most popular with over 75k stars on Github, but Ant Design has now overtaken them with 77.5k!


1 Answers

You can use onChange, why not?

<Input
     placeholder="Flight name"
     size="large"
     value={this.state.someVal || ''}
     onChange={this.onChange}
   />
onChange = (e) => {
  this.setState({someVal: e.target.value})
}
like image 81
Bhojendra Rauniyar Avatar answered Oct 15 '22 03:10

Bhojendra Rauniyar