storybook/docs/snippets/svelte/loader-story.js.mdx
2022-11-17 16:33:22 +01:00

37 lines
862 B
Plaintext

```js
// TodoItem.stories.js
import fetch from 'node-fetch';
import TodoItem from './TodoItem.svelte';
export default {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/7.0/svelte/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Examples/Loader',
component: TodoItem,
};
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/7.0/svelte/api/csf
* to learn how to use render functions.
*/
export const Primary = {
render: (args, { loaded: { todo } }) => ({
Component: TodoItem,
props: {
...args,
todo,
},
}),
loaders: [
async () => ({
todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(),
}),
],
};
```