4 ms·
You could easily wind up with an infinite loop without hooks (for example, by calling `setState` in `componentDidUpdate`).
by dgritsko 6y ago
You could easily wind up with an infinite loop without hooks (for example, by calling `setState` in `componentDidUpdate`).
- jiofih 6y agoThat would be trivial to spot. Not the case with hooks.
- deleted 6y ago[deleted]
- torartc 6y agoIt's trivial to spot with hooks.
- charrondev 6y agoThis is definitely not the case. I’ve seen enough class components with complicated componentDidUpdate methods. The method would then be broken up into multiple other smaller methods (or to re-use some logic in didMount and didUpdate) A few iterations later and you have setState peppered throughout your component. More often then not though I’ve seen a lot of class components that would just fail to update when certain props change. It’s much harder to miss these cases with hooks.