Skip to content

Commit

Permalink
detect globalThis (#2775)
Browse files Browse the repository at this point in the history
`globalThis` is a __standard__ global right now
should use it whenever available
  • Loading branch information
pkit committed Feb 2, 2021
1 parent 3979bee commit a7c1517
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-mangos-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"mobx": patch
---

use globalThis in global detection
3 changes: 3 additions & 0 deletions packages/mobx/src/utils/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ declare const self: any
const mockGlobal = {}

export function getGlobal() {
if (typeof globalThis !== "undefined") {
return globalThis
}
if (typeof window !== "undefined") {
return window
}
Expand Down

0 comments on commit a7c1517

Please sign in to comment.