A

Admin • 833.24K Points
Coach

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

  • (A) render
  • (B) componentDidMount
  • (C) constructor
  • (D) componentWillUnmount
  • Correct Answer - Option(B)
  • Views: 27
  • Filed under category React JS
  • Hashtags:

Explanation by: Admin

componentDidMount is invoked once after the component is mounted and is safe for setting state.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.