-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(execute): Handle async opts #238
Conversation
6d69860
to
6a415cd
Compare
6a415cd
to
0966117
Compare
f9e4cff
to
6798dfd
Compare
@gabrielferreira-imi code looks good can you add a test to confirm that the execute command is stored and called after hCaptcha |
Thanks @gabrielferreira-imi! Need to add one more test to verify the |
0e5f44e
to
4318d25
Compare
4318d25
to
557b338
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zoryana94 mind confirming on your end that all is good as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Facing the issue while executing hCaptcha on the component mount
Suggested changes seem to fix it!
this._onReady = (id) => { | ||
try { | ||
if (opts && opts.async) { | ||
hcaptcha.execute(id, opts).then(resolve).catch(reject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like const hcaptcha = this._hcaptcha;
needs to be also added inside of the this._onReady function
after making this change, it seems to start working:
this._onReady = (id) => {
try {
const hcaptcha = this._hcaptcha;
if (opts && opts.async) {
otherwise, I receive this when executing hCaptcha on the component mount:
src/index.js
Outdated
@@ -327,22 +329,38 @@ class HCaptcha extends React.Component { | |||
} | |||
|
|||
execute (opts = null) { | |||
|
|||
opts = typeof opts === 'object' && opts !== null ? opts : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opts !== null check seems to be redundant
as opts are set to null anyway
opts = typeof opts === 'object' ? opts : null;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on multiple test apps
Should be good now, @gabrielferreira-imi 👍
Fixes #237