|
|
|
|
|
by onsclom
998 days ago
|
|
This example is a bit strange to me. I wonder if `$effect` will actually replace all usage of `onMount` and `onDestroy` for Svelte. In Solid you could totally do these things with `useEffect` too, but they chose to keep `onMount` and `onDestroy` (which they call `onCleanup`) to make this kind of thing more simple. Example: https://www.solidjs.com/examples/counter `onMount` and `onDestroy` feel like really useful, dependable callbacks. `$effect` is scary because if you add a reference to state in it, you can't depend on it being called like `onMount`. |
|
They claim most (but not all) of current usage of `onMount` will be better off using `$effect` instead