Loading

Quipoin Menu

Learn • Practice • Grow

react / Component Lifecycle in React
mcq
Direction: Choose the correct option

Q1.

Which lifecycle method is called when a component is first inserted into the DOM?
A. constructor
B. render
C. componentWillMount
D. componentDidMount
Direction: Choose the correct option

Q2.

Which method is invoked after a component updates due to state or props changes?
A. componentWillUpdate
B. componentDidUpdate
C. shouldComponentUpdate
D. componentDidMount
Direction: Choose the correct option

Q3.

What is the purpose of shouldComponentUpdate?
A. To update the DOM
B. To initialize state
C. To prevent unnecessary re-renders by returning false
D. To perform side effects before update
Direction: Choose the correct option

Q4.

Which method is called right before a component is removed from the DOM?
A. componentWillUnmount
B. unmount
C. componentDidUnmount
D. componentWillUnmount
Direction: Choose the correct option

Q5.

In which lifecycle method should you make API calls in a class component?
A. componentDidMount
B. constructor
C. render
D. componentWillMount