storybook/docs/snippets/svelte/loader-story.mdx.mdx
2022-07-07 19:15:02 +01:00

34 lines
736 B
Plaintext

```md
<!-- TodoItem.stories.mdx -->
import { Meta, Story } from '@storybook/addon-docs';
import TodoItem from './TodoItem.svelte';
import fetch from 'node-fetch';
<Meta title="Examples/Loader" component={TodoItem} />
<!--
👇 Render functions are a framework specific feature to allow you control on how the component renders.
See https://storybook.js.org/docs/7.0/svelte/api/csf
to learn how to use render functions.
-->
<Story
name="Primary"
loaders={[
async () => ({
todo: await (
await fetch('https://jsonplaceholder.typicode.com/todos/1')
).json(),
}),
]}
render={(args, { loaded: { todo } }) => ({
Component: TodoItem,
props: {
...args,
todo,
},
})} />
```