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.

ThemeProvider not working with Rebass

See original GitHub issue

ThemeProvider is not applying theme

To reproduce:

Simple example from the rebass documentation and create-react-app: https://rebassjs.org/getting-started

import React from 'react';
import './App.css';
import {Heading} from 'rebass'
import { ThemeProvider } from '@emotion/react'
import styled from '@emotion/styled'

const theme = ...

function App() {
  return (
      <ThemeProvider theme={theme}>
        <div className="app">
          <Heading fontSize={7}>Hello</Heading>
        </div>
      </ThemeProvider>
  );
}

Expected behavior:

Theme is not applied to Rebass components

Environment information:

  • react version: 4.0
  • @emotion/react version: 11.4

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iChenLeicommented, Jun 9, 2021

https://github.com/emotion-js/emotion/releases/tag/%40emotion%2Freact%4011.0.0 Rename @emotion/core to @emotion/react.

When you write code like import { ThemeProvider } from 'emotion-theming', your code and rebass use same one ThemeContext from @emotion/core, and if your write code like import { ThemeProvider } from '@emotion/react , your code use @emotion/react’s ThemeContext and rebass use @emotion/core 's ThemeContext, so that’s why your code not work as expected. I suggest you use emotion-theming or push rebass library author to support @emotion/react(But it’s looks like inpossible cause rebass is not a active project currently).

0reactions
marcoamonteirocommented, Jun 9, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Theming - Rebass
ThemeProvider. To apply themes to Rebass components, add a ThemeProvider component to the root of your application and pass a theme object as...
Read more >
Rebass not picking up values defined in Theme ui theme
My index file where I wrap the App component with the ThemeProvider. Index.tsx import React from 'react'; import ReactDOM from 'react-dom'; ...
Read more >
React Rebass Theming - GeeksforGeeks
We can customize the theming of project components very easily by using the theme provider. ThemeProvider: We will have to add a theme...
Read more >
Theming - Rebass
To apply themes to Rebass components, add a ThemeProvider component to the root of your application and pass a theme object as a...
Read more >
rebass-sandbox - CodeSandbox
OR use 'rebass/styled-components'. Browser. Tests. (0.46x). Mobile. Console. 0. Problems. 0. React DevTools. 0. All, Info, Warning, Error, Debug. b486fa213.
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