beforeUpdate and afterUpdate
Hook into the update cycle to inspect or modify the DOM before and after reactive changes.
When They Run
beforeUpdate runs before reactive updates flush to DOM; afterUpdate runs immediately after.
Use Cases
Use them to read DOM measurements before changes and adjust scroll position after.
All lessons in this course
- onMount: Running After Render
- onDestroy: Cleanup
- beforeUpdate and afterUpdate
- tick(): Waiting for DOM Updates