Skip to content
Discussion options

You must be logged in to vote

You can access loader results in Svelte CSF stories by using the second argument to your template function, which contains a loaded property. To pass the file from your loader to your component, update your template like this:

{#snippet template(args, { loaded: { file } })}
  <button onclick={() => (open = true)}>open</button>
  <AddMediaDialog {...args} file={file} bind:open />
{/snippet}

Or, if you want to spread all loader results as props:

{#snippet template(args, { loaded })}
  <button onclick={() => (open = true)}>open</button>
  <AddMediaDialog {...args} {...loaded} bind:open />
{/snippet}

This pattern is documented in the official Storybook Svelte CSF examples and works for async…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by brendan-morin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant