Computer Science, asked by Narpavi5878, 1 year ago

What happens when a component returns null from its render method

Answers

Answered by joybiswas100
0

Answer:

using React for a while, but today I started wondering about one thing.

Why componentDidMount method is fired even though my render function returns null?

From the docs:

componentDidMount() is invoked immediately after a component is mounted (inserted into the tree). Initialization that requires DOM nodes should go here. If you need to load data from a remote endpoint, this is a good place to instantiate the network request.

As I understand it correctly: component returns null, so that there's nothing to mount in the DOM tree and componentDidMount should not

Similar questions