storybook/docs/snippets/react/loader-story.js.mdx
2020-10-10 17:41:04 +08:00

15 lines
348 B
Plaintext

```js
// TodoItem.stories.js
import React from 'react';
import fetch from 'node-fetch';
import { TodoItem } from './TodoItem';
export const Primary = (args, { loaded: { todo } }) => <TodoItem {...args} {...todo} />;
Primary.loaders = [
async () => ({
todo: (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
}),
];
```