Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
23574b54
Commit
23574b54
authored
May 06, 2017
by
Arana Jhonny
Committed by
Tim Neutkens
May 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for cxs rehydration and removal of duplicate styles. (#1860)
* add cxs.rehydrate. * add id='cxs-style'.
parent
0abfca26
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
_document.js
examples/with-cxs/pages/_document.js
+2
-2
index.js
examples/with-cxs/pages/index.js
+9
-1
No files found.
examples/with-cxs/pages/_document.js
View file @
23574b54
import
Document
,
{
Head
,
Main
,
NextScript
}
from
'next/document'
import
Document
,
{
Head
,
Main
,
NextScript
}
from
'next/document'
import
cxs
from
'cxs'
import
cxs
from
'cxs
/lite
'
export
default
class
MyDocument
extends
Document
{
export
default
class
MyDocument
extends
Document
{
static
async
getInitialProps
({
renderPage
})
{
static
async
getInitialProps
({
renderPage
})
{
...
@@ -13,7 +13,7 @@ export default class MyDocument extends Document {
...
@@ -13,7 +13,7 @@ export default class MyDocument extends Document {
<
html
>
<
html
>
<
Head
>
<
Head
>
<
title
>
My
page
<
/title
>
<
title
>
My
page
<
/title
>
<
style
dangerouslySetInnerHTML
=
{{
__html
:
this
.
props
.
style
}}
/
>
<
style
id
=
'cxs-style'
dangerouslySetInnerHTML
=
{{
__html
:
this
.
props
.
style
}}
/
>
<
/Head
>
<
/Head
>
<
body
>
<
body
>
<
Main
/>
<
Main
/>
...
...
examples/with-cxs/pages/index.js
View file @
23574b54
import
React
from
'react'
import
React
from
'react'
import
cxs
from
'cxs'
import
cxs
from
'cxs/lite'
// Using cxs/lite on both the server and client,
// the styles will need to be rehydrated.
if
(
typeof
window
!==
'undefined'
)
{
const
styleTag
=
document
.
getElementById
(
'cxs-style'
)
const
serverCss
=
styleTag
.
innerHTML
cxs
.
rehydrate
(
serverCss
)
}
export
default
()
=>
(
export
default
()
=>
(
<
div
className
=
{
cx
.
root
}
>
<
div
className
=
{
cx
.
root
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment