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