1
0
Fork 0
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:
Felix Mosheev 2019-02-14 20:05:08 +02:00 committed by Tim Neutkens
parent 9bb8fbf535
commit 04ce3e7174
2 changed files with 4 additions and 3 deletions

View file

@ -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)

View file

@ -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)