Ant-design: Clear Autocomplete after form submit

Created on 3 Dec 2016  ·  3Comments  ·  Source: ant-design/ant-design

Dear Community,

Ant Design is an awesome ui system and we've been using it extensively for the past few months.
Thank you for designing and open sourcing this lib.

--

I need to clear the AutoComplete component after the form has been submitted.

I have tried to do the following :

...
<AutoComplete ref='toField' />
...

// In a callback 
this.refs.toField.value = null;

But it isn't working. How can this be done ?

Thanks.

Most helpful comment

Do not use ref to control component state, use React state.

http://facebook.github.io/react/docs/forms.html#controlled-components

http://codepen.io/afc163/pen/MbQXRV?editors=001

All 3 comments

Do not use ref to control component state, use React state.

http://facebook.github.io/react/docs/forms.html#controlled-components

http://codepen.io/afc163/pen/MbQXRV?editors=001

@afc163 Thank you.

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings