Skip to content

Module Federation | sx transformed by @jsxImportSource cannot access theme context #2272

Answered by hasparus
daenash asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @daenash, I've spent some time fiddling with this issue, and unfortunately I can only offer you a workaround and my reasoning about the cause of the problem.

So, Theme UI uses React Context, and depends on Emotion that uses React Context. React Contexts are effectively singletons, they won't work as expected if you have a consumer at one version and a provider from another.

I added some more properties to the theme

theme={{
  colors: { "almost-white": "#f0f0f0" },
  space: { large: "100px" },
  breakpoints: ["900px", "1000px", "1100px"],
}}

Then, I changed the contents of Container.js into this

/** @jsxImportSource @emotion/react */

import { css, useThemeUI } from "theme-ui";

const C…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@daenash
Comment options

@daenash
Comment options

Comment options

You must be logged in to vote
2 replies
@daenash
Comment options

@daenash
Comment options

Comment options

You must be logged in to vote
1 reply
@daenash
Comment options

Answer selected by daenash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
2 participants