react-native-masked-text icon indicating copy to clipboard operation
react-native-masked-text copied to clipboard

text.replace is not a function

Open dragonfire1119 opened this issue 6 years ago • 1 comments

With the latest release, this issue is cropping back up https://github.com/benhurott/react-native-masked-text/issues/95#issuecomment-511928816

dragonfire1119 avatar Nov 03 '19 20:11 dragonfire1119

This can happen if the value is something other than a string. For example, if you use 'money' and pass in a value that is a number.

In my case even that was working fine, until I used the MaskService. That's when I got an error if I passed in a number when trying to get raw data from 'money' for example. The value was not converted to a string yet, because it hadn't been changed. React-native-masked-text doesn't change the value to a string if it isn't changed.

The solution was simply to check if it is already a number before trying to format it.

TextInput_tsx

AdamSheaHewett avatar Mar 24 '20 19:03 AdamSheaHewett