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
04ce3e71
Commit
04ce3e71
authored
Feb 14, 2019
by
Felix Mosheev
Committed by
Tim Neutkens
Feb 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use process.browser instead of env probing (#6286)
parent
9bb8fbf5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
_app.js
examples/with-mobx/pages/_app.js
+1
-1
store.js
examples/with-mobx/store.js
+3
-2
No files found.
examples/with-mobx/pages/_app.js
View file @
04ce3e71
...
@@ -21,7 +21,7 @@ class MyMobxApp extends App {
...
@@ -21,7 +21,7 @@ class MyMobxApp extends App {
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
)
super
(
props
)
const
isServer
=
typeof
window
===
'undefined'
const
isServer
=
!
process
.
browser
;
this
.
mobxStore
=
isServer
this
.
mobxStore
=
isServer
?
props
.
initialMobxState
?
props
.
initialMobxState
:
initializeStore
(
props
.
initialMobxState
)
:
initializeStore
(
props
.
initialMobxState
)
...
...
examples/with-mobx/store.js
View file @
04ce3e71
import
{
action
,
observable
}
from
'mobx'
import
{
action
,
observable
}
from
'mobx'
import
{
useStaticRendering
}
from
'mobx-react'
import
{
useStaticRendering
}
from
'mobx-react'
const
isServer
=
typeof
window
===
'undefined'
const
isServer
=
!
process
.
browser
useStaticRendering
(
isServer
)
useStaticRendering
(
isServer
)
class
Store
{
class
Store
{
...
@@ -25,7 +25,8 @@ class Store {
...
@@ -25,7 +25,8 @@ class Store {
}
}
let
store
=
null
let
store
=
null
export
function
initializeStore
(
initialData
)
{
export
function
initializeStore
(
initialData
)
{
// Always make a new store if server, otherwise state is shared between requests
// Always make a new store if server, otherwise state is shared between requests
if
(
isServer
)
{
if
(
isServer
)
{
return
new
Store
(
isServer
,
initialData
)
return
new
Store
(
isServer
,
initialData
)
...
...
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