storybook/docs/snippets/react/loader-story.js.mdx
2021-07-02 21:29:08 +01:00

21 lines
489 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,
title: 'Examples/Loader',
};
export const Primary = (args, { loaded: { todo } }) => <TodoItem {...args} {...todo} />;
Primary.loaders = [
async () => ({
todo: (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
}),
];
```