-
Hi. I find on stackowerflow code import {get_current_component} from 'svelte/internal'
const THISComponent = get_current_component()
function destroySelf(){
THISComponent.$destroy();
} is it correct ? |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
Oct 4, 2024
Replies: 1 comment 2 replies
-
Not really. You should not use anything from There is no official mechanism for this. Usually the code that creates a component should destroy it. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Most components are created via markup so Svelte handles their creation/destruction.
It generally would not make much sense if components can just disappear on their own, it would create a mismatch between markup and what is actually there.