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

不想你离开。 提交于 2020-07-08 12:39:35

问题


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.


回答1:


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})
}


来源:https://stackoverflow.com/questions/52378848/why-is-there-no-onchange-for-input-in-ant-design

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!