Addon-docs: GlobalStyles rendered multiple times
See original GitHub issueDescribe the bug Following the documentation for adding global styles to storybook ends up with multiple global style tags because each story on a docs page creates one instance of the global style. This issue is only related to the docs pages not canvas!
To Reproduce Steps to reproduce the behavior:
- Create a storybook with addon-docs
- Create a component with multiple stories
- Add global styles (see Code snippets -> .storybook/config)
- Click on docs tab
- Inspect dom. You will see the global style tag is rendered once per story
- Switch the stories within the current docs page -> clicks x stories = rendered global style tags
Expected behavior Global tags should be rendered once per docs page
Screenshots
Code snippets
.storybook/config
/** @jsx jsx */
import { css, jsx, Global } from '@emotion/core';
import { addDecorator } from '@storybook/react';
// https://www.learnstorybook.com/design-systems-for-developers/react/en/build/
addDecorator((story) => {
return (
<Fragment>
<Global
styles={css`
body { background: purple; }
`}
/>
{story()}
</Fragment>
);
});
System:
Environment Info:
System:
OS: macOS Mojave 10.14.6
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 12.14.0 - /usr/local/bin/node
Yarn: 1.19.2 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.88
Firefox: 71.0
Safari: 13.0.3
Storybook:
@storybook/react: 5.2.8
@storybook/addon-docs: 5.2.8
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
error when trying to load typescript-written package into react ...
im working on storybook tests for my react-native project. I decided to use react-native-web to run storybook as a website
Read more >Are my components supposed to render multiple times? - Reddit
The component renders twice, even in production build. I understand why, because state changes from its initial value of empty array to an...
Read more >@storybook/addon-docs - npm
DocsPage is a zero-config aggregation of your component stories, text descriptions, docgen comments, props tables, and code examples into clean, ...
Read more >Storybook with Next JS - wesionaryTEAM
I am going to add following addons in this project: @storybook/addon-docs — used for documenting the components.
Read more >component-design-library - npm package - Snyk
Learn more about component-design-library: package health score, popularity, ... Render the global styles once per page */ <GlobalStyle /> ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Docs need improving but it’s described here https://github.com/storybookjs/storybook/blob/master/addons/docs/web-components/README.md#stories-not-inline
Hi @shilman, is
inline={false}
now available? If so where can I find the docs for it?