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.

Theme is empty when importing component outside the Gatsby root

See original GitHub issue

I’m building a component library alongside a Gatsby demo website. The component library is styled with Emotion + theming.

Here is the basic folder structure I have:

src
  components
    button.js
website
  src
    components
      layout.js
    pages
      index.js

My problem is that the button doesn’t get the theme (the theme appears to be {}).

However, if I move the button to website/src/components, the theme gets to the button as expected.

See repro here.

What am I missing here?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Andaristcommented, Aug 29, 2019

@lloydh @dmfilipenko I suspect that you have 2 copies of @emotion/core package in your build, might be because of local linking or because of a monorepo without hoisted node_modules

2reactions
Andaristcommented, Oct 25, 2019

Seems like the issue has been diagnosed and the recommendation for a fix has been given - even though OP has not responded back if he has been able to get this working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Emotion theme is empty when importing component outside ...
I'm building a component library alongside a Gatsby demo website. The component library is styled with Emotion + theming.
Read more >
Building a Theme - Gatsby
In this tutorial, you'll learn how to build a theme plugin for Gatsby. This tutorial is meant as a written companion to the...
Read more >
How To Use Themes in Gatsby - DigitalOcean
In Gatsby, the main theme initialization and configuration is done by editing the root configuration file, gatsby-config.js .
Read more >
Styling themes
This was done for Gatsby Themes, but most of it should be applicable to other ... and one-off styles that made entire components...
Read more >
Basic Features: Fast Refresh - Next.js
js import theme.js , editing theme.js will update both components. Finally, if you edit a file that's imported by files outside of the...
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