storybook/docs/snippets/react/loader-story.js.mdx
2021-06-28 23:00:33 +01:00

16 lines
417 B
Plaintext

```js
// TodoItem.stories.js | TodoItem.stories.jsx | TodoItem.stories.ts | TodoItem.stories.tsx
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(),
}),
];
```