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

Throw a nice error when using the styled shorthand without babel-plugin-emotion and remove duplication in component selector code #516

Merged
merged 4 commits into from
Jan 4, 2018

Conversation

emmatown
Copy link
Member

@emmatown emmatown commented Jan 4, 2018

What:
Throw a nice error when using the styled shorthand without babel-plugin-emotion and remove duplication in component selector code.

Why:

So that people know what to do when they use the shorthand and it doesn't work.

How:

Use a Proxy if it's available and we're in dev. While this won't work in browsers without Proxies I think it's okay since it's just in dev and most people will be using modern browsers for dev.

Checklist:

  • Documentation N/A
  • Tests
  • Code complete

…emotion and remove duplication in component selector stuff
@codecov
Copy link

codecov bot commented Jan 4, 2018

Codecov Report

Merging #516 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted Files Coverage Δ
packages/emotion-utils/src/index.js 100% <ø> (ø) ⬆️
packages/create-emotion-styled/src/index.js 100% <100%> (ø) ⬆️
packages/create-emotion/src/index.js 100% <100%> (ø) ⬆️

@@ -165,6 +164,16 @@ function createEmotionStyled(emotion: Emotion, view: ReactType) {
return Styled
}
}
if (process.env.NODE_ENV !== 'production' && typeof Proxy !== 'undefined') {
createStyled = new Proxy(createStyled, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! Great idea.

@tkh44 tkh44 merged commit d3b55b8 into master Jan 4, 2018
@tkh44 tkh44 deleted the nice-error-for-styled-shorthand branch January 4, 2018 18:37
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

Successfully merging this pull request may close these issues.

2 participants