mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Use process.browser instead of env probing (#6286)
This commit is contained in:
parent
9bb8fbf535
commit
04ce3e7174
|
@ -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)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
Loading…
Reference in a new issue