const [shipping, setShipping] = useState({
overseas: '3'
})
const handleChange = (e) => {
setShipping({ overseas: e.target.value }) //can change to 8 or 3
}
const selection = shipping.overseas
console.log(selection) // value of selection is accurate
const getTotal = () => {
return products.reduce((currentValue, nextValue) => {
return (currentValue + selection + nextValue.count * nextValue.price);
}, 0);
};
currentValue is 0 , selection is either 3 or 8 , nextValue is 23 when calculating the total, instead of adding the actual numbers, it became 0323 instead of 23+3 which is 26