Q. In which lifecycle method is it safe to set state in a class component?

  • (A) render
  • (B) componentDidMount
  • (C) constructor
  • (D) componentWillUnmount
πŸ’¬ Discuss
βœ… Correct Answer: (B) componentDidMount
Explanation: componentDidMount is invoked once after the component is mounted and is safe for setting state.
Explanation by: Mr. Dubey
componentDidMount is invoked once after the component is mounted and is safe for setting state.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
82
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
89%
Success Rate