4

I have a basic if/else in the app to show either a preloader or a component.

{#if preloading}
    <video />
{:else}
    <svelte:component this={component} on:preload={preload}/>
{/if}

It starts with displaying the component correctly, when the preload flag is set, it shows the video, but it shows it over the svelte:component rather than replacing it.

I tried using {#key} to force a rerender by using a number as an id and incrementing it when preload is set, but the component is still there.

Any ideas?

1
  • Same issue for me Commented Jun 21, 2022 at 12:57

1 Answer 1

3

Try doing it like in the repl example:

<script>
  import video from "./somewhere.svelte"
  import component from "./somewhereelse.svelte" 
</script>

<svelte:component this={preloading ? video : component} on:preload={preload}/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.