ParseInt Bug
Int in the model leads to left-pad 0 in the view
by Adam Fiedler
HTML
<div id="app"></div>
React
class ParseIntBug extends React.Component {
constructor(props) {
super(props)
this.state = {value: 0}
}
handle(e) {
let val = parseInt(e.target.value)
if (isNaN(val)) {
val = 0
}
this.setState({value: val});
}
render() {
return (
<div>
<input type="number" value={this.state.value} onChange={this.handle.bind(this)} />
</div>
)
}
}
ReactDOM.render(<ParseIntBug />, document.querySelector("#app"))