Svelte Lifecycle Method - afterUpdate
In Svelte, a component's  afterUpdate  lifecycle method  is called  after  the component is updated as a result of a state change. When the value of any of a component's props and variables changes, the component's  beforeUpdate  lifecycle method is executed prior to any DOM updates being made in response to these changes. Once the  beforeUpdate  lifecycle method is finished running, the DOM is updated to reflect the data changes. After completing this update, the  afterUpdate  lifecycle method is executed. Being able to schedule a callback to run at this phase of a component's lifecycle ensures that the DOM is completely updated and synced with any new state and prop values. Here's a template of how the  afterUpdate  lifecycle method is used inside of a component: When using the  afterUpdate  lifecycle method, remember that it runs on every state and prop change. For components that experience many state and prop changes, it can be quite cumbersome to track which variables/props have changed in order to then execute the appropriate code. This is unlike React's  componentDidUpdate  lifecycle method , which provides the previous props and state as arguments.