0

I have a function to format numbers which I use in my project in React Native

function formatedNumber(value){
  return value ? parseFloat(value).toLocaleString("pt-br", {minimumFractionDigits: 2 }) : "0.00"
}

and example of using

<Text style={{fontSize:16}}>Valor of the value: {obj.value!= null && <Text>{formatedNumber(obj.value)}</Text>}</Text>

The problem is that on it shows formatted value ( so instead 10000 shows 10.000,00) only when I am on debugging mode, otherwise the value stays unformatted.

Versions

"expo": "^33.0.0",

"react": "16.8.3",

"react-native": "0.61.2"

user0810
  • 886
  • 5
  • 19
  • 33
  • What do you mean by "only shows in debugging mode"? Are you able to see the `Text` component? or just the value – Ian Vasco Oct 07 '19 at 13:01
  • I m able to see Text Component but without formated value so like "Valor of the value: 1000" instead of "Valor of the value: 1.000,00 ". But when I start debbuing mode I can see that the code stop on formatedNumber func and the values appear formated on the screen – user0810 Oct 07 '19 at 13:41
  • 1
    If you're using Android, this could be the issue: https://stackoverflow.com/a/55861894 – Zaytri Oct 07 '19 at 23:29
  • 2
    Answer here: https://github.com/facebook/react-native/issues/19410 – Oleg Oct 08 '19 at 06:36

0 Answers0