Replies: 1 comment
-
It looks like the linked docs are wrong, for what it's worth, as they say that children are cleaned up first. I recall that switching this order fixed some kind of issue but I honestly can't remember what it was. Question 2. Components don't have lifecycles, they are one-time setup functions. Cleanups follow the reactive graph, i.e., the nested dynamic parts of your app. Question 1. There are simple ways to delay running some code (like wrapping The relevant function, in which parent cleanups run first. It's possible that running parent cleanups after children would actually be correct here, I would just hesitate to change it before I remember what the bug was that caused this ordering in the first place! leptos/leptos_reactive/src/runtime.rs Lines 193 to 212 in b1e8105 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I could confirm that cleanup_fn of parent components are run before their children's counterparts. But sometimes the programmer need to reverse this order when using some third party libraries.
Question 1: How could we run cleanup code for children components before their parents' cleanup?
Question 2: How to hook into component's life cycle to run code just before removal of it's DOM content?
Hint: Think about this as I'm trying to achieve onDestroy(() => { /* cleanup code */ }) from svelte.
Beta Was this translation helpful? Give feedback.
All reactions