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.

10.0.7 not working with Create React App

See original GitHub issue
  • emotion version: 10.0.7
  • react version: 16.8.1

Relevant code:

import { jsx, css } from '@emotion/core'

const CloseButton = ({ onClick, children }) => (
  <button css={css`
      background: red;
   `}
   onClick={() => onClick()}>
    { children }
  </button>
)

What you did:

  1. Created a new project with Create React App.
  2. Installed Emotion
  3. Tried to use css

What happened: It renders [object Object]:

<button class="[object Object]">Close</button>

Reproduction: https://codesandbox.io/s/7k11o3q1q1

Problem description: I may be missing something here… Every example I find in the docs makes it seem this simple, but I can’t seem to get it working with CRA. See example (https://codesandbox.io/s/7k11o3q1q1). Maybe an issue with CRA’s implementation of babel, and the dependencies of emotion?

Suggested solution: It’d be nice to get an error instead of just [object Object].

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
km860commented, Feb 12, 2019

Is there a better way to utilize emotion in CRA that doesn’t require using that comment in any component that you need to use emotion in?

Not according to the docs (https://emotion.sh/docs/css-prop). 😞

3reactions
km860commented, Feb 11, 2019

You have to add this code snippet (from: https://emotion.sh/docs/install) at the top before you import, /** @jsx jsx */

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create React App not working - Stack Overflow
1. update the npm version (npm install npm@latest -g) · 2. clear the cache (npm cache clean --force) · 3. create the react...
Read more >
create-react-app - npm
Create React apps with no build configuration. ... Start using create-react-app in your project by running `npm i create-react-app`.
Read more >
create-react-app - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >
Npm install problem when creating my first react app
npm ERR! network request to http://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND proxy.company.com
Read more >
How to Install and Setup a React App on Windows 10
Running the Application. So the app we created can run locally on our system with the npm start command. cd awesome-project npm start....
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