storybook/docs/snippets/react/loader-story.mdx.mdx
2022-07-07 19:47:29 +01:00

28 lines
687 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.
See https://storybook.js.org/docs/7.0/react/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 } }) => <TodoItem {...args} todo={todo} />} />
```