Type error: Cannot read property data of null
See original GitHub issueGetting an error thrown by both Preact & React with the following message:
Uncaught TypeError: Cannot read property 'data' of null
I have tried to debug this issue, but it seems like there’s something going on deeper in Goober. I believe the issue is caused here, in this minified file:
![Screenshot 2020-05-07 at 14 41 30](https://user-images.githubusercontent.com/1145427/81295784-40239780-9071-11ea-9952-3c7b3fa6d299.png)
When I reload the page, everything seems to be fine again, so it doesn’t happen every render 🤔 Any help is appreciated 😃
Cheers!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (9 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'data' of null - node.js
As the error explains your queryResult property is null. Add another conditional check to see if the queryResult field is not empty in...
Read more >Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >TypeError: Cannot read property 'value' of Null in JS
To solve the "Cannot read property 'value' of null" error, make sure that the JS script tag is placed at the bottom of...
Read more >How to deal with TypeError: cannot read properties of null
While coding in Javascript, you must have at least once received a Type Error which has the message “cannot read properties of null”....
Read more >Cannot read property 'data' of null - Developing with Prismic
Hi there, I'm having some trouble getting my image to render consistently. The problem is that my state is not updating on initial...
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
Heyo! @mjanssen thanks for opening this issue.
TL;DR; goober expects a textNode to exist inside the style tag. Meaning in here https://github.com/mjanssen/nextjs-goober/blob/master/pages/_document.js#L21 you should do
html: ' ' + this.props.css
.The
textNode
exists so goober can avoid the reflow/repaint from updating the contents, via atextNode.data
property update. This one is a really odd one TBH, and tried before to move toinsertRule
which could lead to better perf, but in goober’s case the metrics were the same.I think this should be documented somewhere, or at least part of the
next-with-goober
example somewhere.Ahh yes you got it right. The style element exists but its
firstChild
is null. That’s why it errors.The easiest fix on your side could be to just put a space before extractCss