How to make a numeric input in react be empty if the value is set to 0

372 views Asked by At

Here is the code I am rendering : The numeric input at the start is empty - which I want and once I change it to a number e.g 2 and then bring it back down it stays on 0. Any ideas how to keep it empty if there is no value inside?

array = ['a', 'b', 'c', 'd']

@observer export default class Widget extends React.Component {

    @observable abc = _.fill([], 0, 0, 27);//[0,0,0,0,0,0] [1,0,0,0,]
    @action changeValueHandler(value, index) {
        this.abc[index] = value;
    }

    render() {

         const abLabels = array.map((curLetter, index) =>
            <div>
                <div>
                    <ControlLabel key={index} value={curLetter} className="letters">{curLetter}</ControlLabel>
                </div>
                <div>
                    <NumericInput key={index} className="numericUpDown" onChange={(value) => this.changeValueHandler(value, index)} precision={0} value={this.abc[index]} step={1} min={0}/>
                </div>
            </div>)

        return (
            <div>
                <ul>{abLabels}</ul>
                <br /><br /><br />
           </div>
        );
    }
}
0

There are 0 answers