Theme is empty when importing component outside the Gatsby root
See original GitHub issueI’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:
- Created 4 years ago
- Reactions:4
- Comments:8 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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_modulesSeems 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.