We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorator in Svelte are always executed twice during story rendering. However Svelte components in decorators are (correctly) only mounted once.
npm run storybook
Storybook Environment Info: System: OS: Linux 5.0 undefined CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Shell: 1.0 - /bin/jsh Binaries: Node: 18.18.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.4.2 - /usr/local/bin/npm <----- active pnpm: 8.9.2 - /usr/local/bin/pnpm npmPackages: @storybook/addon-essentials: ^7.5.1 => 7.5.1 @storybook/addon-interactions: ^7.5.1 => 7.5.1 @storybook/addon-links: ^7.5.1 => 7.5.1 @storybook/blocks: ^7.5.1 => 7.5.1 @storybook/svelte: ^7.5.1 => 7.5.1 @storybook/sveltekit: ^7.5.1 => 7.5.1 @storybook/testing-library: ^0.2.2 => 0.2.2 storybook: ^7.5.1 => 7.5.1
A simple workaround is to move any logic in the decorator that is not supposed to run twice, from the decorator into a Svelte component's onMount.
Before:
// preview.js ... decorators: [ (Story) => { // some code that cannot run twice return Story(); }, ] ...
After:
// preview.js import MyDecorator from './MyDecorator.svelte'; ... decorators: [ () => MyDecorator, ] ...
// MyDecorator.svelte <script> import { onMount } from 'svelte'; onMount(() => { // some code that cannot run twice }) </script> <slot/>
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe the bug
Decorator in Svelte are always executed twice during story rendering. However Svelte components in decorators are (correctly) only mounted once.
To Reproduce
npm run storybook
System
Additional context
A simple workaround is to move any logic in the decorator that is not supposed to run twice, from the decorator into a Svelte component's onMount.
Before:
After:
The text was updated successfully, but these errors were encountered: