ref
This commit is contained in:
@@ -32,22 +32,26 @@
|
||||
value: '',
|
||||
}
|
||||
});
|
||||
this.input.focus();
|
||||
} else {
|
||||
this.setState({
|
||||
result: '땡',
|
||||
value: '',
|
||||
});
|
||||
this.input.focus();
|
||||
}
|
||||
}
|
||||
|
||||
onChange = (e) => this.setState({ value: e.target.value});
|
||||
|
||||
onRefInput = (c) => { this.input = c; };
|
||||
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div>{this.state.first} 곱하기 {this.state.second} 는?</div>
|
||||
<form onSubmit={this.onSubmit}>
|
||||
<input type="number" value={this.state.value} onChange={this.onChange}/>
|
||||
<input ref={this.onRefInput} type="number" value={this.state.value} onChange={this.onChange}/>
|
||||
<button>입력!</button>
|
||||
</form>
|
||||
<div>{this.state.result}</div>
|
||||
|
||||
Reference in New Issue
Block a user