Styled Component styles are disabled in Chrome DevTools

后端 未结 4 1716
我寻月下人不归
我寻月下人不归 2020-12-30 00:39

I am working on a static page that uses React, Gatsby, and styled-components.

When styling a page, my development workflow usually heavily involves Chrome DevTools,

相关标签:
4条回答
  • 2020-12-30 01:29

    At a guess, I'd say you might be affected by this bug:

    https://bugs.chromium.org/p/chromium/issues/detail?id=796629

    If you close the dev tools and reopen them again, this might fix the issue temporarily.

    0 讨论(0)
  • 2020-12-30 01:33

    I did a full quit of Chrome (Cmd + q), ran npm update, npm install, and did a full relaunch of the browser and localhost server. This fixed it for me.

    0 讨论(0)
  • 2020-12-30 01:36

    It's because styled-components injects styles through the CSSOM API, which the Dev Tools in Chrome (and every other browser AFAIK) can't handle. See this ticket: https://bugs.chromium.org/p/chromium/issues/detail?id=387952

    Note that this is only true when styled-components is in production mode, i.e. process.env.NODE_ENV is set to "production". As long as you aren't in production mode, styled-components should generate normal <style> tags, which you can interact with through the Dev Tools.

    0 讨论(0)
  • 2020-12-30 01:36

    In v4.1.0 it's possible to provide SC_DISABLE_SPEEDY flag to disable styles injection with CSSOM insertRule.

    More details
    https://www.styled-components.com/releases#v4.1.0
    https://github.com/styled-components/styled-components/pull/2185

    0 讨论(0)
提交回复
热议问题