Skip to content

Commit c756166

Browse files
committed
add refreshExpired
1 parent 6f96e74 commit c756166

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

HISTORY.md

Lines changed: 8 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+
### Added
11+
12+
- `refreshExpired` option
13+
1014
### Changed
1115

1216
- Temporary load callback function is now removed after load
@@ -16,6 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1620
- `onTimeout` callback not properly registering
1721
- `ref` not passing properly - pass `userRef` instead
1822

23+
### Removed
24+
25+
- `autoResetOnExpire` - use `refreshExpired` instead
26+
1927
## [1.0.6] - 2022-11-25
2028

2129
### Added

src/index.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function Turnstile({
5757
responseFieldName,
5858
retry,
5959
retryInterval,
60-
autoResetOnExpire,
60+
refreshExpired,
6161
userRef,
6262
onVerify,
6363
onLoad,
@@ -92,17 +92,15 @@ export default function Turnstile({
9292
theme,
9393
size,
9494
tabindex: tabIndex,
95-
callback: (token: string) => inplaceState.onVerify(token),
96-
"error-callback": () => inplaceState.onError?.(),
97-
"expired-callback": () => {
98-
inplaceState.onExpire?.();
99-
if (autoResetOnExpire) window.turnstile.reset(widgetId);
100-
},
101-
"timeout-callback": () => inplaceState.onTimeout?.(),
10295
"response-field": responseField,
10396
"response-field-name": responseFieldName,
10497
retry,
10598
"retry-interval": retryInterval,
99+
"refresh-expired": refreshExpired,
100+
callback: (token: string) => inplaceState.onVerify(token),
101+
"error-callback": () => inplaceState.onError?.(),
102+
"expired-callback": () => inplaceState.onExpire?.(),
103+
"timeout-callback": () => inplaceState.onTimeout?.(),
106104
};
107105

108106
widgetId = window.turnstile.render(ref.current, turnstileOptions);
@@ -123,7 +121,7 @@ export default function Turnstile({
123121
responseFieldName,
124122
retry,
125123
retryInterval,
126-
autoResetOnExpire,
124+
refreshExpired,
127125
]);
128126
useEffect(() => {
129127
inplaceState.onVerify = onVerify;
@@ -147,8 +145,7 @@ interface TurnstileProps extends TurnstileCallbacks {
147145
responseFieldName?: string;
148146
retry?: "auto" | "never";
149147
retryInterval?: number;
150-
autoResetOnExpire?: boolean;
151-
148+
refreshExpired?: "auto" | "manual" | "never";
152149
id?: string;
153150
userRef?: React.MutableRefObject<HTMLDivElement>;
154151
className?: string;

0 commit comments

Comments
 (0)