question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type error: Cannot read property data of null

See original GitHub issue

Getting 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

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
cristianbotecommented, May 7, 2020

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 a textNode.data property update. This one is a really odd one TBH, and tried before to move to insertRule 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.

2reactions
lucat1commented, May 7, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found