storybook/docs/snippets/react/loader-story.mdx.mdx
2021-11-03 23:31:14 +00:00

25 lines
485 B
Plaintext

```md
<!-- TodoItem.stories.mdx -->
import { Meta, Story } from '@storybook/addon-docs';
import fetch from 'node-fetch';
import { TodoItem } from './TodoItem';
<Meta title="Examples/Loader" component={TodoItem} />
<Story
name="Primary"
loaders={[
async () => ({
todo: await (
await fetch('https://jsonplaceholder.typicode.com/todos/1')
).json(),
}),
]}>
{(args, { loaded: { todo } }) => (
<TodoItem {...args} todo={todo} />
)}
</Story
```