marsidev / react-turnstile

Cloudflare Turnstile integration for React.
https://www.npmjs.com/package/@marsidev/react-turnstile
MIT License
414 stars 25 forks source link

fix: resetting widgets solved ref back to false on widget unmount #76

Closed kkatsi closed 4 months ago

kkatsi commented 4 months ago

This PR aims to fix #75

I discovered that when the widget was unmounted and then remounted without using the reset() function, the widgetSolved state reference was not reset to false. This issue arises in cases where the widget's dynamic cData changes, causing a reset or re-render of the widget. If widgetSolved.current is set to true, it breaks the getResultPromise() function, resulting in a "No response received" error.

The issue has been fixed by setting widgetSolved.current back to false on the widget's unmount.

codesandbox[bot] commented 4 months ago

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders
Open Preview

vercel[bot] commented 4 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-turnstile ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2024 7:27pm
marsidev commented 4 months ago

For some reason, the e2e tests are failing

kkatsi commented 4 months ago

@marsidev Do you think that this is related to the changes? They also fail locally, when i try to run them.

marsidev commented 4 months ago

I don't think so. They're also failing in the main branch locally

marsidev commented 4 months ago

Thanks! @kkatsi