marsidev / react-turnstile

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

issue: getResponsePromise throws 'No response received' error, when widget resets by changing cData #75

Closed kkatsi closed 4 months ago

kkatsi commented 4 months ago

Hi, i got a question (potential bug?). Here is the case. I initialize the turnstile widget giving it specific cData value. Then i get the token through ref using promise await ref.current?.getResponsePromise();. After that action i got a button, that clicking on it, the cData value of the widget changes, resetting the widget. The next time i try to get token with await ref.current?.getResponsePromise(); it throws the 'No response received' error. I created a reproducable repo

codesandboxUrl To reproduce:

My actual goal is to silently initialize the widget. Then when a user clicks a button i want to retrieve the token if possible without any UI change. If thats not possible i want to show the widget and wait for user's input. Have you got in mind another approach that would may be more efficient for my goal? I really appreciate any help.

Thanks in advance!