JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/react@latest/dist/react-with-addons.js"></script>
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script>
<div id="container"></div>
Babel + JSX
class App extends React.Component {
state = { value: '' }
onChange = (value) => {
const VALUE = parseFloat(value);
console.log(VALUE >= 0 && !isNaN(VALUE) ? value : '')
this.setState({ value: VALUE >= 0 && !isNaN(VALUE) ? value : '' });
}
render() {
return (
<div>
<input type="number"
value={typeof this.state.value !== 'undefined' && this.state.value !== null ? this.state.value : ''}
onChange={e => this.onChange(e.target.value)} />
</div>
);
}
}
ReactDOM.render(<App name="world"/>, document.getElementById('container'));