storybook/docs/snippets/vue/loader-story.mdx.mdx
2021-10-11 19:57:39 +01:00

30 lines
688 B
Plaintext

```md
<!-- TodoItem.stories.mdx -->
import { Meta, Story } from '@storybook/addon-docs';
import TodoItem from './TodoItem.vue';
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 } }) => ({
components: { TodoItem },
setup() {
return { args, todo: todo };
},
template: '<TodoItem :todo="todo" />',
})} />
```