question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Addon-docs: GlobalStyles rendered multiple times

See original GitHub issue

Describe 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:

  1. Create a storybook with addon-docs
  2. Create a component with multiple stories
  3. Add global styles (see Code snippets -> .storybook/config)
  4. Click on docs tab
  5. Inspect dom. You will see the global style tag is rendered once per story
  6. 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 2020-01-03_1235

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:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
shilmancommented, Jun 5, 2020
0reactions
smollweidecommented, Jun 5, 2020

Hi @shilman, is inline={false} now available? If so where can I find the docs for it?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found