A

Admin • 833K Points
Coach

Q. How can you prevent a component from rendering in React?

  • (A) Return null from the render method or functional component
  • (B) Call event.preventDefault()
  • (C) Use componentDidMount lifecycle method
  • (D) Remove the component from the DOM manually
  • Correct Answer - Option(A)
  • Views: 15
  • Filed under category React JS
  • Hashtags:

Explanation by: Admin

Returning null tells React to render nothing for that component.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.