I have a state as value: 10.00 and once I update it with some operation and add it to a <Text> the “.00” part gets trimmed off. If it was a value like 10.50, it’ll be displayed as 10.5
This is a issue as I want to display currency values. How to handle this?
Advertisement
Answer
Found the answer. To have the value with decimal values, use toFixed() method.
Example:
var value = 10;
value = value.toFixed(2);
this.setState({subTotal: value});
The output would be: 10.00