-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add useTheme hook for emotion-theming #1499
Conversation
🦋 Changeset is good to goLatest commit: c7ac0b6 We got this. Not sure what this means? Click here to learn what changesets are. |
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the one comment, SGTM
@@ -0,0 +1,7 @@ | |||
// @flow | |||
import * as React from 'react' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing 👇 will mean that emotion-theming won't break for people who aren't on >=16.8.0
import * as React from 'react' | |
import React from 'react' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitchellhamilton import * as React from 'react'
was always supported, this ain't nothing to do with [email protected]. And also - the wildcard is somewhat more correct than the default export. Or maybe you were referencing something I'm not aware of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that it would fail for users who aren't on >=16.8.0
because rollup would change import * as React from 'react
' to import { useContext } from 'react'
and that export wouldn't exist so it would fail. Though I guess since React is CJS, it wouldn't have failed? I'd still rather leave it as import React from 'react'
though just in case someone uses an ESM bundle of React and aliased it or rollup users with rollup-plugin-commonjs because of the namedExports
option or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting edge cases. I guess technically they are possible so yeah - let's keep the default for now.
* Add useTheme hook for emotion-theming * Add changeset * Small fixes to imports and docs * Update theming.mdx
What:
Add
useTheme
hook to emotion-themingWhy:
Sometimes this is more convenient for theming than relying on the functional argument in the css prop. This is especially true with object styles or projects that have existing styles and are moving to theming. Instead of refactoring every css call to be a function this is a much simpler update.
How:
Checklist: