Svelte: Dynamic component rendering

PHOTO EMBED

Fri Sep 08 2023 13:14:00 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #javascript #svelte

<script>
  import ExperimentOne from './ExperimentOne.svelte';
  import ExperimentTwo from './ExperimentTwo.svelte';
 
  let component = (Math.random() * 100) > 50 ? 
    ExperimentTwo :
    ExperimentOne;
</script>
 
<svelte:component this={component} />
content_copyCOPY