I am creating a svelte component in use:action function and I need to get add dynamic content inside the component. Does svelte allow to replace slot during or after creation of a svelte component?
Example code
export default function (node: HTMLElement) {
let component = new Component({
props: {},
target: node,
// maybe this
slot: anotherComponent,
});
// or this
component.slot = anotherComponent;
return {
update() {},
destroy() {
component.$destroy();
},
};
}
That is currently not supported, though that is a popular feature request. As noted in the issue, you can use private APIs at the peril of them breaking at any point.
You might be able to work around this by exposing an element of the component and mounting the child component there.