-1
Hello, I am developing an application that makes a calculation of electricity consumption in React Native.
In it, I have 2 pickers: one of hours and the other of minutes. And to make it easier on the account I’m converting the minutes into hours, but at the time of adding up the hours and minutes it just puts one next to the other!
Example: The user has selected that his device is on for 5:30 a day. I convert the 30 minutes into hours: 30 / 60 = 0.5, and together with the 5 hours: 5.5 hours
But the application returns me the value one beside the other and not summed as in the image:
So is the assembly of my function:
function handleSubmit() {
const convertedHour = hour + (min / 60);
alert(convertedHour)
}
const [hour, setHour] = useState('00');
const [min, setMin] = useState('00');
Set an initial state with number and not string. If necessary, do type conversion.
– Cmte Cardeal