From 04ce3e7174e67b8bcc8749ecc2bb437edc953fb3 Mon Sep 17 00:00:00 2001 From: Felix Mosheev <9304194+felixmosh@users.noreply.github.com> Date: Thu, 14 Feb 2019 20:05:08 +0200 Subject: [PATCH] Use process.browser instead of env probing (#6286) --- examples/with-mobx/pages/_app.js | 2 +- examples/with-mobx/store.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/with-mobx/pages/_app.js b/examples/with-mobx/pages/_app.js index ef5d8e75..e47e00ee 100644 --- a/examples/with-mobx/pages/_app.js +++ b/examples/with-mobx/pages/_app.js @@ -21,7 +21,7 @@ class MyMobxApp extends App { constructor(props) { super(props) - const isServer = typeof window === 'undefined' + const isServer = !process.browser; this.mobxStore = isServer ? props.initialMobxState : initializeStore(props.initialMobxState) diff --git a/examples/with-mobx/store.js b/examples/with-mobx/store.js index 7ff8f48a..7fbecba1 100644 --- a/examples/with-mobx/store.js +++ b/examples/with-mobx/store.js @@ -1,7 +1,7 @@ import { action, observable } from 'mobx' import { useStaticRendering } from 'mobx-react' -const isServer = typeof window === 'undefined' +const isServer = !process.browser useStaticRendering(isServer) class Store { @@ -25,7 +25,8 @@ class Store { } let store = null -export function initializeStore(initialData) { + +export function initializeStore (initialData) { // Always make a new store if server, otherwise state is shared between requests if (isServer) { return new Store(isServer, initialData)