Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThemeProvider not passing theme object to imported child component #252

Closed
tbrasington opened this issue Jul 30, 2019 · 2 comments
Closed

Comments

@tbrasington
Copy link

Hi

This maybe a quirk of the setup I have running with how I bundle the component package. Hoping somewhere here has a better idea than I do!

Environment

  • I am importing component package bundled with microbundle
  • Example app running zeit/next.js (also tried with create-react-app)
  • theme-ui for styling

Example Code

<ThemeProvider theme={theme}>
  <Button text="foo" />
  <SomeOtherComponent>
</ThemeProvider>

Error Message related to the component

Warning: Prop `className` did not match. Server: "css-0" Client: "css-10audxd-Button"

Button is the component from the package that isn't receiving the theme object.
SomeOtherComponent is a relative component that gets the theme object.

For reference, this is the Button component

/** @jsx jsx */
import { jsx } from 'theme-ui'
// Component
export const Button = ({
  text,
  children,
  kind,
}) => {
  return (
    <button sx={{ variant: `buttons.${kind}` }}>
      {text || children}
    </button>
  )
}

Button.defaultProps = {
  kind: "primary"
};

Other notes

  • Button renders the theme correctly in its relative package via parcel
  • Button renders correctly in the same import setup with Framer X

Any help is appreciated!

@tbrasington tbrasington changed the title ThemeProvider not passing theme object to child component ThemeProvider not passing theme object to imported child component Jul 30, 2019
@Marujah
Copy link

Marujah commented Apr 1, 2021

hi, why is this closed? I sitll have the same issue

@lachlanjc
Copy link
Member

lachlanjc commented Apr 1, 2021

hi, why is this closed? I sitll have the same issue

Hey! You're most likely encountering mismatched Emotion versions. See here: #1531 @Marujah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants