alkafinance / react-native-amount-input

⚛️ React Native JS-only amount (decimal) input component
MIT License
13 stars 0 forks source link

BRL currency prefix only shows 1 letter #7

Open Grohden opened 4 years ago

Grohden commented 4 years ago
    const [a,b] = useState(0)

    return (
        <AmountInput
            currency='BRL'
            defaultQuantity={ a }
            onChangeQuantity={ b }
        />
    )

renders R0.00, when it should render R$0.00 (actually it should be using ',' tho)

The issue is on this line https://github.com/alkafinance/react-native-amount-input/blob/a1ff9f444afb83e31916890ea6be2f1b0065d288/src/AmountInput.tsx#L70

removing the [0] fixes for me, but I'm not sure why it has this index access

Grohden commented 4 years ago

but I'm not sure why it has this index access

now I know, without it the prefix will be prefix0.00. a quick hack is to use

        const [prefix] = formatter.format(0).split('0');

        return prefix