React Hooks

This commit is contained in:
haerong22
2020-12-19 15:39:37 +09:00
parent 73976a7349
commit 5b2b6214fc

View File

@@ -24,7 +24,7 @@
const onSubmitForm = (e) => {
e.preventDefault();
if(parseInt(this.state.value) === this.state.first * this.state.second) {
if(parseInt(value) === first * second) {
setResult('정답: ' + value);
setFirst(Math.ceil(Math.random() * 9));
setSecond(Math.ceil(Math.random() * 9));
@@ -38,14 +38,14 @@
}
return (
<React.Fragment>
<div>{first} 곱하기 {second}?</div>
<form onSubmit={}>
<input ref={inputRef} onChange={onChangeInput} value={value} />
<button>입력!</button>
</form>
<div id="result">{result}</div>
</React.Fragment>
<React.Fragment>
<div>{first} 곱하기 {second}?</div>
<form onSubmit={onSubmitForm}>
<input ref={inputRef} onChange={onChangeInput} value={value} />
<button>입력!</button>
</form>
<div id="result">{result}</div>
</React.Fragment>
);
}