What happens when a component returns null from its render method
Answers
Answered by
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
Computer Science,
6 months ago
English,
6 months ago
Geography,
1 year ago
Physics,
1 year ago
English,
1 year ago