Cannot read property 'style' of null
See original GitHub issuereact-google-recaptcha version: 1.0.5 react-async-script version: N/A
This error only seems to happen when recaptcha suspects that I’m a robot and shows me the annoying pictures of cars/buses/etc.
This is the error:
Uncaught TypeError: Cannot read property 'style' of null
at B (VM952 recaptcha__en.js:181)
at iC.<anonymous> (VM952 recaptcha__en.js:482)
B @ recaptcha__en.js:181
(anonymous) @ recaptcha__en.js:482
setTimeout (async)
a @ recaptcha__en.js:106
f0 @ recaptcha__en.js:482
BG @ recaptcha__en.js:484
t.NP @ recaptcha__en.js:506
r.W @ recaptcha__en.js:325
(anonymous) @ recaptcha__en.js:325
jN @ recaptcha__en.js:12
next @ recaptcha__en.js:12
G @ recaptcha__en.js:14
Promise.then (async)
w @ recaptcha__en.js:14
(anonymous) @ recaptcha__en.js:14
cs @ recaptcha__en.js:14
$v @ recaptcha__en.js:13
Qa @ recaptcha__en.js:325
(anonymous) @ recaptcha__en.js:322
VA @ recaptcha__en.js:90
A2 @ recaptcha__en.js:92
J2.G @ recaptcha__en.js:89
My code:
<ReCAPTCHA
ref={e => (this.recaptchaInstance = e)}
sitekey="my-key"
size="invisible"
onChange={this.verifyCaptchaCallback}
onExpired={() => this.recaptchaInstance.reset()}
onErrored={err => console.error(`Recaptcha error: ${err}`)}
/>
executeCaptcha = () => {
this.recaptchaInstance.execute()
}
verifyCaptchaCallback = async response => {
...
}
The error doesn’t seem to have any negative effect, so it seems to match what’s written here (https://github.com/google/google-api-javascript-client/issues/281), i.e, that it can be ignored. But that same issue seems to mention a fix: https://github.com/google/google-api-javascript-client/issues/281#issuecomment-339077537
So maybe this library can use this fix?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:30
- Comments:9
Top Results From Across the Web
JavaScript TypeError: Cannot read property 'style' of null
The possible reason behind the error is that the JavaScript runs much earlier than the objects it requires from the webpage are loaded....
Read more >How To Fix Cannot Read Property 'style' of Null in JavaScript
This error boils down to one problem. The element you are trying to access does not exist in the DOM (document object model)...
Read more >JavaScript TypeError Cannot Read Property 'style' of Null
JavaScript TypeError Cannot Read Property 'style' of Null ... A typeerror is thrown when a value is not of the expected type. Unlike...
Read more >Cannot read property 'style' of Null in JavaScript | bobbyhadz
To resolve the "Cannot read property 'style' of null" error, make sure that the DOM element you're accessing the style property on exists....
Read more >how to fix this error Cannot read property of null (reading 'style')
how to fix this error Cannot read property of null (reading 'style') ... Hi Andrew,. he's just saying that boxElement is null. That...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there any update on this issue? I’m continuing to get this error when Recaptcha suspects that I’m a robot and shows me the annoying pictures of cars/buses/etc.
The only thing that worked for me is setting a timeout before resetting the recaptcha
setTimeout(() => recaptchaRef.current.reset(), 500);
Not the best approach, and not 100% crash-free but it doesn’t crash every time.