storybook/docs/snippets/react/loader-story.js.mdx
2021-08-28 01:52:57 +01:00

25 lines
502 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 default {
component: TodoItem,
};
export const Primary = {
render: (args, { loaded: { todo } }) => {
return <TodoItem {...args} {...todo} />;
},
loaders: [
async () => ({
todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
}),
],
};
```