Skip to content

Conversation

@zoryana94
Copy link
Contributor

Relates to #189

Before

Screen.Recording.2025-02-06.at.15.28.52.mov

After

Screen.Recording.2025-02-06.at.15.30.00.mov

@zoryana94 zoryana94 requested a review from a team as a code owner February 6, 2025 13:35
Comment on lines +50 to +52
if (this._hcaptcha) {
return;
}
Copy link
Collaborator

@brdlyptrs brdlyptrs Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this is correct? This check only validates whether the API has loaded within the current window context.

If you continue to follow the logic of this function, we then use this specific later to determine if we should even render hCaptcha or load the API. If the API is loaded, then the render function will be called. From here the render function checks if a captcha already exists by referencing the id of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought if it's safer to use state.captchaId
in general, this logic works as expected, as this._hcaptcha is set only in componentDidMount, so renderCaptcha is still called

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks as the safe solution to me as it's the way to ensure that componentDidMount is called only once
we could actually use any other variable for that
also React.StrictMode calls componentDidMount twice only on dev mode, so it should be safe especially on prod

however, as the alternative, we could go with this PR: #251
please take a look

@brdlyptrs @vladislav-nick-imi @damian-rodriguez-imi

@zoryana94 zoryana94 closed this Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants