You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am storing the value in state and after submitting the form I am clearing the state, The state is getting cleared but number in the form is not getting cleared as I see the value is already there in DOM.
`
this._mapPropsToState = function (props) {
var firstCall = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false
var inputNumber = void 0;
if (props.value) {
inputNumber = props.value;
} else if (props.initialValue && firstCall) {
inputNumber = props.initialValue;
} else if (_this3.props.value) {
// just clear the value
inputNumber = '';
} else if (_this3.state && _this3.state.formattedNumber && _this3.state.formattedNumber.length > 0) {
inputNumber = _this3.state.formattedNumber;
} else {
inputNumber = '';
}
var selectedCountryGuess = _this3.guessSelectedCountry(inputNumber.replace(/\D/g, ''));
var selectedCountryGuessIndex = findIndex(propEq('iso2', selectedCountryGuess.iso2), allCountries);
var formattedNumber = (0, _format_number2.default)(inputNumber.replace(/\D/g, ''), selectedCountryGuess ? selectedCountryGuess.format : null, _this3.props.autoFormat);
console.log('formattedNumber -->', formattedNumber)
return {
selectedCountry: selectedCountryGuess,
highlightCountryIndex: selectedCountryGuessIndex,
formattedNumber: formattedNumber
};
};
`
Consoled formattedNumber and I see it is not getting cleared.
I used initialValue instead of value so the issue came up. @mukeshsoni Please make sure you update the Doc value and initialValue Both the props have the same purpose - for setting the initial value of the input programatically.
Describe the bug
I am storing the value in state and after submitting the form I am clearing the state, The state is getting cleared but number in the form is not getting cleared as I see the value is already there in DOM.
`
this._mapPropsToState = function (props) {
};
`
Consoled
formattedNumber
and I see it is not getting cleared.How I can I make it clear? @mukeshsoni
Expected behavior
Clear the input value when state is cleared.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: