Skip to content

Commit 39d643c

Browse files
committed
fix globalThis check (#9)
1 parent a21309e commit 39d643c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020

2121
- `onTimeout` callback not properly registering
2222
- `ref` not passing properly - pass `userRef` instead
23+
- `globalThis` errors on older browsers
2324

2425
### Removed
2526

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useState, useRef } from "react";
22
import { TurnstileOptions, SupportedLanguages } from "turnstile-types";
33

4-
const global = (globalThis ?? window) as any;
4+
const global = (typeof globalThis !== "undefined" ? globalThis : window) as any;
55
let turnstileState =
66
typeof global.turnstile !== "undefined" ? "ready" : "unloaded";
77
let ensureTurnstile: () => Promise<any>;

0 commit comments

Comments
 (0)