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

23 lines
554 B
Plaintext

```js
// TodoItem.stories.js
import fetch from 'node-fetch';
/*
*👇 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: 'demo-todo-item',
render: (args, { loaded: { todo } }) => TodoItem({ ...args, ...todo }),
};
export const Primary = {
loaders: [
async () => ({
todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
}),
],
};
```