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

Clear Autocomplete after form submit #4122

Closed
shivekkhurana opened this issue Dec 3, 2016 · 3 comments
Closed

Clear Autocomplete after form submit #4122

shivekkhurana opened this issue Dec 3, 2016 · 3 comments

Comments

@shivekkhurana
Copy link

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.

@afc163
Copy link
Member

afc163 commented Dec 4, 2016

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 afc163 closed this as completed Dec 4, 2016
@shivekkhurana
Copy link
Author

@afc163 Thank you.

@lock
Copy link

lock bot commented May 3, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants