From fbe835a91fb77f159fbc27adc56c1a020296c56b Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Mon, 21 Jan 2019 09:55:51 +0100 Subject: [PATCH] Make sure isolateGlobalState is called first, fixes#1869 --- src/api/configure.ts | 6 +++--- test/base/strict-mode.js | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/api/configure.ts b/src/api/configure.ts index 38647e61a..f01e7cd55 100644 --- a/src/api/configure.ts +++ b/src/api/configure.ts @@ -19,6 +19,9 @@ export function configure(options: { disableErrorBoundaries, reactionScheduler } = options + if (options.isolateGlobalState === true) { + isolateGlobalState() + } if (enforceActions !== undefined) { if (typeof enforceActions === "boolean" || enforceActions === "strict") deprecated( @@ -49,9 +52,6 @@ export function configure(options: { if (computedRequiresReaction !== undefined) { globalState.computedRequiresReaction = !!computedRequiresReaction } - if (options.isolateGlobalState === true) { - isolateGlobalState() - } if (disableErrorBoundaries !== undefined) { if (disableErrorBoundaries === true) console.warn( diff --git a/test/base/strict-mode.js b/test/base/strict-mode.js index 11b4c1a13..50394c4c0 100644 --- a/test/base/strict-mode.js +++ b/test/base/strict-mode.js @@ -240,3 +240,12 @@ test("warn on unsafe reads", function() { mobx.configure({ computedRequiresReaction: false }) } }) + +test("#1869", function() { + const x = mobx.observable.box(3) + mobx.configure({ enforceActions: "always", isolateGlobalState: true }) + expect(() => { + x.set(4) + }).toThrow("Since strict-mode is enabled") + mobx._resetGlobalState() // should preserve strict mode +})