R202_-_SU_2024_-_Block_5_-_FE_2670.webp
free_spirit

R202_-_SU_2024_-_Block_5_-_FE_2670.webp

Kizspy | Question: 7 (Choose 1 answer)
import React, { Component } from 'react';
class Counter extends Component { constructor(props) {
super(props);this.state = {
count: 0
incrementCount() {
};}// TODO: Increase the count state by 1 } </div>);
render() {
return ( <div>
<p>Count: {this.state.count}</p><button onClick={this.incrementCount}>Increment</button>
export default Counter;
In the code above, how can we increase the value of the count state by 1 when the user clicks the "Increment"button?
A. Call the method this.setState({ count: this.state.count + 1}) inside the incrementCount method.
B. Assign a new value to count using the assignment operator (=) inside the incrementCount method.
C. Call the method this.state.count += 1 inside the incrementCount method.
D. Use this.setState(count + 1) inside the incrementCount method.
FUOVER
  • Like
Reactions: Quangdung

Thông tin

Category
FER202
Thêm bởi
free_spirit
Ngày thêm
Lượt xem
2,302
Lượt bình luận
12
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom