Loading

Quipoin Menu

Learn • Practice • Grow

react / setState Method in React
mcq
Direction: Choose the correct option

Q1.

In a class component, which method is used to update state?
A. this.updateState()
B. this.setState()
C. this.state = {}
D. this.replaceState()
Direction: Choose the correct option

Q2.

What is the behavior of setState?
A. It replaces the entire state object
B. It schedules an update and may batch multiple calls
C. It only works in constructor
D. It immediately updates the state
Direction: Choose the correct option

Q3.

When you call setState with an object, what does React do?
A. Ignores it
B. Replaces the entire state
C. Throws an error
D. Merges the object with current state
Direction: Choose the correct option

Q4.

Why might you pass a function to setState instead of an object?
A. To access previous state reliably when updates are batched
B. To avoid merging
C. Because objects are not allowed
D. To improve performance
Direction: Choose the correct option

Q5.

After calling setState, which lifecycle method is invoked?
A. All of the above
B. shouldComponentUpdate
C. render
D. componentDidUpdate