Handling Side Effects & Working with the useEffect() HookEntry 7 of 7

Summary

ConceptReactAngular
Run a side effect after renderuseEffecteffect() / afterRenderEffect()
Run once on setupuseEffect(fn, [])ngOnInit / constructor / afterNextRender
DependenciesListed by hand in an arrayTracked automatically from signal reads
Skip a dependencyNot allowed (restructure instead)untracked()
Derived valuesCompute in render / useMemocomputed()
Cleanup per runReturned functiononCleanup()
Cleanup on destroyReturned function ([] effect)DestroyRef / ngOnDestroy
Stable function identityuseCallback / React CompilerClass methods
Infinite loops possible?YesYes (writing a signal the effect reads)

Both frameworks agree on the principle: effects are for synchronizing with the outside world, not for computing state. React makes you declare dependencies and manage function identity; Angular tracks signal dependencies and keeps methods stable, but a misused effect() can loop just the same.