File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,9 +89,18 @@ export class HCaptcha extends React.Component {
8989 return ;
9090 }
9191
92- // Reset any stored variables / timers when unmounting
93- hcaptcha . reset ( captchaId ) ;
94- hcaptcha . remove ( captchaId ) ;
92+ try {
93+ // Reset any stored variables / timers when unmounting
94+ hcaptcha . reset ( captchaId ) ;
95+ hcaptcha . remove ( captchaId ) ;
96+ } catch ( error ) {
97+ // Silently handle errors (e.g., invalid captcha ID in React Strict Mode)
98+ // This can happen when React double-invokes effects in development
99+ } finally {
100+ // Always clear state to prevent issues in React Strict Mode
101+ this . captchaId = '' ;
102+ this . _onReady = null ;
103+ }
95104 }
96105
97106 shouldComponentUpdate ( nextProps , nextState ) {
Original file line number Diff line number Diff line change 11{
22 "name" : " @hcaptcha/react-hcaptcha" ,
33 "description" : " A React library for hCaptcha" ,
4- "version" : " 2.0.1 " ,
4+ "version" : " 2.0.2 " ,
55 "author" : " hCaptcha team and contributors" ,
66 "license" : " MIT" ,
77 "repository" : {
You can’t perform that action at this time.
0 commit comments