storybook/docs/snippets/react/loader-story.js.mdx
2021-02-23 00:26:03 +00:00

16 lines
349 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(),
}),
];
```