Commit 04ce3e71 authored by Felix Mosheev's avatar Felix Mosheev Committed by Tim Neutkens

Use process.browser instead of env probing (#6286)

parent 9bb8fbf5
...@@ -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)
......
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment