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.

createGlobalStyle not being auto formatted

See original GitHub issue

Anything inside another styled tag will be properly formatted, for example a styled.div. But a createGlobaStyle function will not have it’s contents formatted. Color is still being applied, but formatting won’t happen.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:21

github_iconTop GitHub Comments

40reactions
alikadircommented, Feb 14, 2020

flowing code works 💪

import * as styled from 'styled-components';

export default styled.createGlobalStyle`
  body {
    margin: 0;
  }
  code {
    font-family: source-code-pro;
  }
`;

39reactions
danielmahoncommented, Jun 20, 2019

Same issue, not sure of any side-effects yet but as a workaround, I’m just wrapping the whole thing in the css function, which seems to re-enable the auto-formatting.

import { createGlobalStyle, css } from 'styled-components';

export default createGlobalStyle`${css`
  html,
  body,
  #root {
    padding: 0px;
    margin: 0px;
    width: 100vw;
    height: 100vh;
  }
`}`;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier is not formatting my Styled Components code
This is the code that I am expecting to get after formatting through Prettier and Eslint (but I am not) : import {...
Read more >
FAQs - styled-components
In general, always use the css helper when composing styling partials to be interpolated into a styled component.. import styled, { keyframes } ......
Read more >
React Styled Components - 10 - Global Styles - YouTube
10 React Antipatterns to Avoid - Code This, Not That! ... Python Tutorial: Logging Basics - Logging to Files, Setting Levels, and Formatting....
Read more >
Setting Up Styled Components
It lets us create React components with styles automatically ... The answer is no — Styled Components has something called createGlobalStyle ...
Read more >
How To Use React Styled Components Efficiently - Copycat
Unused CSS Cleanup: it automatically cleans up CSS declarations not in use, consequently reducing file size and bundle size.
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