<input
type="number"
value={this.number1}
onChange={() => this.handleChange}
/>
//where is can correct this
this.updateData()}>Click me
it's very simple to add two input box value
class Example extends React.Component {
constructor(props) {
super(props);
this.state = {
inputState : {
a : '' , b : '' , res : ''
}
};
}
render() {
return (
<div>
<h1>{`res : ${this.state.inputState.res}` }</h1>
<input
onChange = {(e) => this.setState ({ ...inputState , a : e.target.value})}
/>
<input
onChange = {(e) => this.setState ({ ...inputState , b : e.target.value})}
/>
<button onClick={() => this.setState({ ...inputState , res: this.state.inputState.a + this.state.inputState.b })}>
Click me
</button>
</div>
);
}
}