0

Will componentDidUpdate always fire for a component that renders empty fragment/null ? It receives redux connected props from the parent container.

This component needs to access previous props and compare, then make an API call based on it. It doesn't have UI, so it renders empty fragment (or null)

EDIT : It is working and firing componentDidUpdate in my sample application. Is this guaranteed to be the behavior always? It says here that there is a chance it may not fire when there was no change in the virtual DOM: Props updated, componentDidUpdate did not fire

MyContainer
 |
  -MyComponent
Sector0
  • 309
  • 3
  • 15

2 Answers2

1

Yes it run every time instead at time of first initial render

Umair
  • 419
  • 1
  • 4
  • 13
0

Yes componentDidUpdate is called every time, even when rendering null. You can check this in the react documentation: React Lifecycle

costal oktopus
  • 319
  • 2
  • 12
  • This wasn't mentioned anywhere in the documents. I had to look up in react's github to find this - https://github.com/reactjs/reactjs.org/pull/1230/commits/ff21b379265572607989fc309ddf6a914417a09d – Sector0 May 09 '19 at 03:51