Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Props updated, componentDidUpdate did not fire

Is there ever a situation where componentDidUpdate would NOT fire, even if the props updated in React?

like image 789
J Seabolt Avatar asked Jun 22 '18 20:06

J Seabolt


1 Answers

There are 3 conditions that can cause componentDidUpdate to not fire:

1) You wrote a custom shouldComponentUpdate that returned false.

2) The internal react methods determined that there was no change in the virtual DOM, so it chose not to re-render.

3) You extended something other than React.Component (such as PureComponent) which has a default shouldComponentUpdate method that returned false.

like image 165
Nathan Christian Avatar answered Nov 10 '22 16:11

Nathan Christian