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 63f2cf5 commit fbe835a
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 @@ -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(
Expand Down Expand Up @@ -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(
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 fbe835a

Please sign in to comment.