mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 07:21:16 +08:00
21 lines
489 B
Plaintext
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(),
|
|
}),
|
|
];
|
|
``` |