How to convert string into number into rect native?
I have a function that receives two parameters of type number (2.6), but when I send them from one screen to another it is received as a string.
How do I do the conversion?
How to convert string into number into rect native?
I have a function that receives two parameters of type number (2.6), but when I send them from one screen to another it is received as a string.
How do I do the conversion?
It worked for me like this:
Number(string);
Converting a string
to number
into React Native is the same problem as doing this in JavaScript, which is the language used by the framework. So just use parseFloat()
:
parseFloat("123.45") // => 123.45 (Number)
Another more "exotic" way of converting is by using the plus sign:
+"123.45" // => 123.45