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
1773b991
Unverified
Commit
1773b991
authored
Feb 07, 2021
by
Michael McQuade
Committed by
GitHub
Feb 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[examples] Wrap entire app with Styletron provider for with-styletron (#21908)
parent
958bd6ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
package.json
examples/with-styletron/package.json
+4
-4
_document.js
examples/with-styletron/pages/_document.js
+15
-7
No files found.
examples/with-styletron/package.json
View file @
1773b991
...
@@ -8,10 +8,10 @@
...
@@ -8,10 +8,10 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"next"
:
"latest"
,
"next"
:
"latest"
,
"react"
:
"
^16.8.0
"
,
"react"
:
"
17.0.1
"
,
"react-dom"
:
"
^16.8.0
"
,
"react-dom"
:
"
17.0.1
"
,
"styletron-engine-atomic"
:
"
^1.1.2
"
,
"styletron-engine-atomic"
:
"
1.4.6
"
,
"styletron-react"
:
"
^5.0.1
"
"styletron-react"
:
"
5.2.7
"
},
},
"license"
:
"MIT"
"license"
:
"MIT"
}
}
examples/with-styletron/pages/_document.js
View file @
1773b991
...
@@ -3,14 +3,22 @@ import { Provider as StyletronProvider } from 'styletron-react'
...
@@ -3,14 +3,22 @@ import { Provider as StyletronProvider } from 'styletron-react'
import
{
styletron
}
from
'../styletron'
import
{
styletron
}
from
'../styletron'
class
MyDocument
extends
Document
{
class
MyDocument
extends
Document
{
static
getInitialProps
(
props
)
{
static
async
getInitialProps
(
context
)
{
const
page
=
props
.
renderPage
((
App
)
=>
(
props
)
=>
(
const
renderPage
=
()
=>
<
StyletronProvider
value
=
{
styletron
}
>
context
.
renderPage
({
<
App
{...
props
}
/
>
enhanceApp
:
(
App
)
=>
(
props
)
=>
(
<
/StyletronProvider
>
<
StyletronProvider
value
=
{
styletron
}
>
))
<
App
{...
props
}
/
>
<
/StyletronProvider
>
),
})
const
initialProps
=
await
Document
.
getInitialProps
({
...
context
,
renderPage
,
})
const
stylesheets
=
styletron
.
getStylesheets
()
||
[]
const
stylesheets
=
styletron
.
getStylesheets
()
||
[]
return
{
...
page
,
stylesheets
}
return
{
...
initialProps
,
stylesheets
}
}
}
render
()
{
render
()
{
...
...
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