I got really strange situation. I need to change value of input, if its not passed validation:
if (!isValid) {
//if invalid set previous value
this.timeInput.input.value = previous value;
}
I am using masked input, but with vanilla inputs behaviour completely the same.
And I got situation that my input updates, just before next rerender was called. Its my first question - why? Ok, after some research i found the solution - add key to the input, as said there add -
<input key={Math.random()}/>
And its work! But there is strangest, when I tried to change value from random to my id property, something like -
key={Number(this.props.id)}
It doesnt work! Why? One difference its only that my id is whole number (like 3), but Math.random return something like 0.21421214124.
Aucun commentaire:
Enregistrer un commentaire