Open GSolari79 opened 5 years ago
same problem) I want to create a controlled component
A hacky workaround, but if you provide a key
prop to the component you can change it to force a new component to be created/mounted. It doesn't strictly reset the instance you have, but it gives the appearance of resetting.
this.phone.state.inputValue = "";
this.phone.state.formattedNumber = "";
This resets the phone number
If you want to maintain the current dialling code on the input field, the following works for me:
const ISOCode = this.phoneInput.getISOCode()
this.phoneInput.setState({ iso2: undefined }, () => {
this.phoneInput.selectCountry(ISOCode)
})
If you are working with functional component you can use:
phoneInput.current?.setState({number: 0})
If you are working with functional component you can use:
phoneInput.current?.setState({number: 0})
setState
does not seem to be defined in the type
I would like to reset the value of the PhoneInput. Does anyone know how to do it?
Really appreciated.