RN mask link https://github.com/text-mask/text-mask/blob/reactNativeMasks/reactnative/src/reactNativeTextMask.js
The reason why text-mask is better than others is it doesn'y rely on onKeyUp
or any key events.
This makes it much more reliable on mobile devices w/ Samsung generally screwing events up w/ custom browser crap they build on top of chrome.
It only deals with previous value, next value, and cursor position.
Those are all typically accessible in onChange
(sync) which allows us to make reliable updates for the value, as well as the new cursor position.
In RN they are 2 separate calls. So it makes it a little more difficult as rather than onChange
things need to be handled in onSelectionChange
However when we then control the selection value via setNativeProps
we get called again.
Ideally in onChange
, new value as well as new cursor position would be exposed.
A new call that combines them all is a little less than ideal since most people rely on onChange
and onChangeText
.
As well as the potential to use preventDefault
. However I haven't seen a prevelance of this on RN much.
I thinks we could normalize TextInput events to always include the selection, value and content size. That way no matter what event you use (either onChange, onSelectionChange or both) you get all the data you need to compute the new value and selection.