함수형 setState

This commit is contained in:
haerong22
2020-12-17 16:23:53 +09:00
parent 3c513b6401
commit aafc454629

View File

@@ -24,12 +24,13 @@
onSubmit = (e) => {
e.preventDefault();
if(parseInt(this.state.value) === this.state.first * this.state.second) {
this.setState({
result: this.state.first + ' * ' + this.state.second
+ ' = ' + this.state.first * this.state.second + ' 정답',
this.setState((prevState) => {
return {
result: '정답 : ' + prevState.value,
first: Math.ceil(Math.random() * 9),
second: Math.ceil(Math.random() * 9),
value: '',
}
});
} else {
this.setState({