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

Support for create-react-app? #166

Closed
MakiBM opened this issue Jul 19, 2017 · 3 comments
Closed

Support for create-react-app? #166

MakiBM opened this issue Jul 19, 2017 · 3 comments

Comments

@MakiBM
Copy link
Contributor

MakiBM commented Jul 19, 2017

So I have a fresh app boostrapped with create react app. Added emotion to the project and trying to use it. Below is the error message I get. Any help on that one?

  • emotion version: 6.0.3
  • react version: 15.6.1

Relevant code.

import React from 'react'
import styled from 'emotion/react'

const Header = styled.div`
  display: flex;
  width: 100%;
`

Error message

TypeError: __WEBPACK_IMPORTED_MODULE_1_emotion_react___default.a.div is not a function
Object../src/components/Header.js
src/components/Header.js:4
  1 | import React from 'react'
  2 | import styled from 'emotion/react'
  3 | 
> 4 | const HeaderClass = styled.div`
  5 |   display: flex;
  6 |   width: 100%;
  7 | `
@emmatown
Copy link
Member

emmatown commented Jul 19, 2017

The most likely reason why you're getting that error is you don't have the babel plugin. Currently we recommend using react-app-rewired if you're using create-react-app, you can look at an example of this here.

In the future if create-react-app adds babel-macros it'll be as simple as importing emotion/react/macro.

@tkh44
Copy link
Member

tkh44 commented Jul 19, 2017

There is actually a preset for emotion here. https://github.com/osdevisnot/react-app-rewire-emotion

@MakiBM
Copy link
Contributor Author

MakiBM commented Jul 20, 2017

Thx guys for directions :)

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

No branches or pull requests

3 participants