docs: use `$effect.pre` instead of `beforeUpdate` (#13955)

* Update 03-lifecycle-hooks.md

* Update documentation/docs/06-runtime/03-lifecycle-hooks.md

Co-authored-by: Paolo Ricciuti <ricciutipaolo@gmail.com>

---------

Co-authored-by: Paolo Ricciuti <ricciutipaolo@gmail.com>
pull/13880/merge
Tee Ming 1 week ago committed by GitHub
parent ac6d8c0bf4
commit 430c2bb129
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -67,12 +67,13 @@ While there's no "after update" hook, you can use `tick` to ensure that the UI i
```svelte ```svelte
<script> <script>
import { beforeUpdate, tick } from 'svelte'; import { tick } from 'svelte';
beforeUpdate(async () => { $effect.pre(() => {
console.log('the component is about to update'); console.log('the component is about to update');
await tick(); tick().then(
console.log('the component just updated'); console.log('the component just updated');
);
}); });
</script> </script>
``` ```

Loading…
Cancel
Save