-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get widget id? #5
Comments
Would you be fine with the onload callback including the widgetId? function TurnstileTest() {
const [widgetId, setWidgetId] = useState(null);
setEffect(() => {
if(!widgetId) return;
// reset widget after 10s
const timeoutId = setTimeout(() => {
turnstile.reset(widgetId);
}, 10000)
return () => clearTimeout(timeoutId)
}, [widgetId])
return <Turnstile
sitekey="..."
onVerify={...}
onLoad={widgetId => setWidgetId(widgetId)}
/>
} Do note that the onLoad callback can be called multiple times if the widget has to be re-created because an important prop changes (theme, sitekey, action etc). |
Yes, that would be fine :) |
v1.0.4 has been published on NPM. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to the docs the render function will return the widget-id:
-- https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/
I need this widgetId to call
window.turnstile.reset(widgetId)
in order to reset the captcha.The text was updated successfully, but these errors were encountered: