I have a simple onChange which takes the user's input pareses it and sets the state to render. Here is the code.
import React, { Component } from 'react';
import './App.css';
class App extends Component {
constructor() {
super();
this.state = {
random: {
foo: 0
}
}
}
onChange(e) {
let random = this.state.random;
random[e.target.name] = parseFloat(e.target.value);
this.setState({random});
}
render() {
return (
<div className="App">
<input onChange={this.onChange.bind(this)} type="text" name="foo" value={this.state.random.foo} />
</div>
);
}
}
export default App;
What I don't understand is where my decimal is going. I know there is no validation in place to stop the user from entering letters, but this is just a sample app to test this issue I ran into. When I enter a decimal point in does not get rendered. Where am I going wrong?