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

Encourage creating globals outside render cycle #2970

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 16 additions & 11 deletions docs/globals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,27 @@ Sometimes you might want to insert global css like resets or font faces. You can
// @live
import { Global, css } from '@emotion/react'

// For performance, move global styles outside of the render cycle when possible
const hotPink = css`
.some-class {
color: hotpink !important;
}
`

const someClass = {
'.some-class': {
fontSize: 50,
textAlign: 'center'
}
}

render(
<div>
<Global
styles={css`
.some-class {
color: hotpink !important;
}
`}
styles={hotPink}
/>
<Global
styles={{
'.some-class': {
fontSize: 50,
textAlign: 'center'
}
}}
styles={someClass}
/>
<div className="some-class">This is hotpink now!</div>
</div>
Expand Down