Closed nandorojo closed 2 years ago
This works fine on the current input library FWIW
Good to know... anyway, I just got it fixed on release v1.1.0
@CaioQuirinoMedeiros hi!
Still doesn't work on v1.1.0
If I put in 1000
, it shows ,1000
instead of 1,000
Can this be reopened?
import MaskInput, { createNumberMask } from 'react-native-mask-input';
import React from 'react'
const dollarMask = createNumberMask({
delimiter: ',',
separator: '.',
precision: 0
})
export default function MyComponent() {
const [value, setValue] = React.useState('');
return (
<MaskInput
value={value}
mask={dollarMask}
onChangeText={(masked, unmasked) => {
setValue(unmasked); // you can use the masked value as well
// assuming you typed "123456":
console.log(masked); // "U$ 1,234.56"
console.log(unmasked); // "123456"
}}
style={{ fontSize: 40}}
autoFocus
/>
);
}
@aprilmintacpineda fixed on v1.1.1
I'm trying to use this for a mask, so that you can only use integer dollar values like
$200
, but it ends up prepending a decimal:And if you enter 4 digits, it's totally off:
Any suggestions on how to get around this @CaioQuirinoMedeiros?
Snack: https://snack.expo.dev/@nandorojo/humiliated-pretzel
Full code here: