Open hadeji33 opened 5 months ago
In your example, you get input control both if you pass an external value
and vice versa. Perhaps your example is incomplete?
Starting with @react-input/mask@2.0.0
, we removed the input-mask
event and the onMask
method, focusing only on using native React events and methods such as onChange
, since the input-mask
event cannot be explicitly coordinated with React events and methods, making such usage and event firing order non-obvious.
To use the useful data from the detail
property of the input-mask
(onMask
) event object, you can also use the utilities described in the «Utils» section.
The release of @react-input/mask@2.0.0
is expected next week.
Tip: Don't change internal and external state at the same time, this applies not only to this library but to all components that have internal state.
When adding the onMask handler, the value of the input field changes even if we strictly specified the value prop of the element. This can be demonstrated by modifying the original example as follows:
We can see this when we want to implement a controlled input component that receives value and onChange props from outside: