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.

Error when using styled-component macro with gatsby

See original GitHub issue

Environment

System:

  • OS: macOS 10.14.5
  • CPU: (4) x64 Intel® Core™ i7-7567U CPU @ 3.50GHz
  • Memory: 386.38 MB / 16.00 GB
  • Shell: 5.6.1 - /usr/local/bin/zsh

Binaries:

  • Node: 10.16.0 - ~/.volta/tools/image/node/10.16.0/6.9.0/bin/node
  • Yarn: 1.16.0 - ~/.volta/tools/image/yarn/1.16.0/bin/yarn
  • npm: 6.9.0 - ~/.volta/tools/image/node/10.16.0/6.9.0/bin/npm
  • Watchman: 4.9.0 - /usr/local/bin/watchman

npmPackages:

  • styled-components: ^5.0.0-beta.3 => 5.0.0-beta.3

Steps to reproduce

  • start a project with gatsby starter
  • install styled-component. same error on v4 and v5
  • In a component, try:
import styled from "styled-components/macro";
const RedDiv = styled.div`
  color: red;
`;

Expected Behavior

  • No error when running gatsby develop

Actual Behavior

  • I see this error in the console: error There was an error trying to load the config "styledComponents" for the macro imported from "styled-components/macro. Please see the error thrown for more information.
  • The code still compiles and works

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11

github_iconTop GitHub Comments

35reactions
dephiroscommented, Jun 18, 2019

Adding config section to package.json fixed it

  "babelMacros": {
    "styledComponents": {
      "pure": true
    }
  }
14reactions
asiopcommented, Aug 12, 2019

above fix also works with create-react-app 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tooling - styled-components
By adding a unique identifier to every styled component, this plugin avoids checksum mismatches due to different class generation on the client and...
Read more >
Cannot access 'Component' before initialization - Stack Overflow
This error appears when you try to style a Child component that has been defined after its parent.
Read more >
Could not find declaration file for 'styled-components'
The error "could not find declaration file for module 'styled-components'" occurs when TypeScript cannot find the type declaration for a styled-components- ...
Read more >
gatsby-typescript-tailwind-twin.macro-styled-component-starter
DevHausStudio/Gatsby-Typescript-Tailwind-Twin-Styled-Component-Starter. This Sandbox is in sync with master on GitHub. You have to fork to make changes
Read more >
Twin.macro Tutorial for Beginners: Styling with Tailwind CSS ...
We are all done. Next, we will make use of twin.macro to create and style components. Note, to set up VSCode to give...
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