Skip to content

Commit 3ec433d

Browse files
committed
use useRef instead of createRef (closes #4)
1 parent 0a7a283 commit 3ec433d

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

HISTORY.md

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

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Race condition by using `useRef` instead of `createRef` (#4)
13+
1014
## [1.0.2] - 2022-10-05
1115

1216
### Added

src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, createRef, useState } from "react";
1+
import React, { useEffect, useState, useRef } from "react";
22

33
const global = globalThis ?? window;
44
let turnstileState =
@@ -56,7 +56,7 @@ export default function Turnstile({
5656
onError,
5757
onExpire,
5858
}: TurnstileProps) {
59-
const ref = createRef<HTMLDivElement>();
59+
const ref = useRef<HTMLDivElement>();
6060
const inplaceState = useState<TurnstileCallbacks>({ onVerify })[0];
6161

6262
useEffect(() => {

0 commit comments

Comments
 (0)