mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 03:21:49 +08:00
31 lines
634 B
Plaintext
31 lines
634 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 -->
|
|
|
|
<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,
|
|
},
|
|
})}
|
|
/>
|
|
``` |