Skip to content

Commit

Permalink
Make sure isolateGlobalState is called first, fixes#1869
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Jan 21, 2019
1 parent 379e1f0 commit 44dd3c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/api/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export function configure(options: {
arrayBuffer,
reactionScheduler
} = options
if (options.isolateGlobalState === true) {
isolateGlobalState()
}
if (enforceActions !== undefined) {
if (typeof enforceActions === "boolean" || enforceActions === "strict")
deprecated(
Expand Down Expand Up @@ -48,9 +51,6 @@ export function configure(options: {
if (computedRequiresReaction !== undefined) {
globalState.computedRequiresReaction = !!computedRequiresReaction
}
if (options.isolateGlobalState === true) {
isolateGlobalState()
}
if (disableErrorBoundaries !== undefined) {
if (disableErrorBoundaries === true)
console.warn(
Expand Down
9 changes: 9 additions & 0 deletions test/base/strict-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

0 comments on commit 44dd3c2

Please sign in to comment.