storybook/docs/snippets/react/loader-story.js.mdx
2023-11-27 20:57:51 -07:00

26 lines
593 B
Plaintext

```js
// TodoItem.stories.js|jsx
import fetch from 'node-fetch';
import { TodoItem } from './TodoItem';
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/api/csf
* to learn how to use render functions.
*/
export default {
component: TodoItem,
render: (args, { loaded: { todo } }) => <TodoItem {...args} {...todo} />,
};
export const Primary = {
loaders: [
async () => ({
todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
}),
],
};
```