storybook/docs/snippets/react/loader-story.mdx.mdx
2021-10-12 21:52:15 +01:00

24 lines
586 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} />
<!-- 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 } }) => <TodoItem {...args} todo={todo} />} />
```