Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/src/component/HCaptcha.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ export class HCaptcha extends React.Component {
return;
}

// Reset any stored variables / timers when unmounting
hcaptcha.reset(captchaId);
hcaptcha.remove(captchaId);
try {
// Reset any stored variables / timers when unmounting
hcaptcha.reset(captchaId);
hcaptcha.remove(captchaId);
} catch (error) {
// Silently handle errors (e.g., invalid captcha ID in React Strict Mode)
// This can happen when React double-invokes effects in development
} finally {
// Always clear state to prevent issues in React Strict Mode
this.captchaId = '';
this._onReady = null;
}
}

shouldComponentUpdate(nextProps, nextState) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hcaptcha/react-hcaptcha",
"description": "A React library for hCaptcha",
"version": "2.0.1",
"version": "2.0.2",
"author": "hCaptcha team and contributors",
"license": "MIT",
"repository": {
Expand Down
Loading
Loading