R202_-_SP_2024_-_FE_1550.webp
nhunghoang

R202_-_SP_2024_-_FE_1550.webp

Answer (Choose 1 answer)
import React. { Component } from 'react';
class Counter extends Component {
constructor(props) { super(props):
this.state = {
D }:
}
count: 0
incrementCount() {
// TODO: Increase the count state by 1
}
render() {
return (
<div>
<p>Count: {this.state.count}</p>
<button onClick={this.incrementCount}>Increment</button>
</div>
):
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. Call the method this.state.count += 1 inside the incrementCount method.
C. Use this.setState(count + 1) inside the incrementCount method.
D. Assign a new value to count using the assignment operator (=) inside the incrementCount method.
2

Thông tin

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

Image metadata

Filename
R202_-_SP_2024_-_FE_1550.webp
File size
75.8 KB
Dimensions
1926px x 906px

Share this media

Back
Bên trên Bottom