I have an text input box on my form, and when the form initially displays it displays the price with a decimal point like 910.01.
const initialState: OrderWindowState = {
price1: 910.01,
price2: 911.33,
}
const [state, setState] = useState<OrderWindowState>(initialState);
<input type="text" name="price1" value={state.price1} onChange={price1OnChange} />
const price1OnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
event.preventDefault();
console.log("price1OnChange called:" + event.target.value);
setState({
...state,
price1: +event.target.value
})
};
When I begin to update the number, if I enter a decimal point . I can see it in my console.log message, but the number stored in my state and visibly in my text input it only displays integer values (with no decimal values).
Why is it doing this?