함수형 setState
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user