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.

`Uncaught TypeError: Cannot read property 'textContent' of null` with SSR in next.js

See original GitHub issue

Here is my react page:

import { motion } from "framer-motion";
import styled from "styled-components";

const Outer = styled(motion.div)`
  height: 100vh;
  display: flex;
  place-items: center;
  background-color: #232323;
`;

const Inner = styled(motion.div)`
  height: 100px;
  width: 100px;
  background-color: cadetblue;
  border-radius: 5px;
`;

const Framer = () => (
  <Outer>
    <Inner>
      Hey
    </Inner>
  </Outer>
);

export default Framer;

This is located under the /pages folder in a next.js app.

With <Inner>Hey</Inner>, it all works fine, but change this to <Inner /> and it consistently gives me Uncaught TypeError: Cannot read property 'textContent' of null when rendering on the server.

This has been a consistent problem whilst I’m getting to grips with next.js. It’s hampering my production.

Error is reproduced on next.js@9.2.0 and next.js@9.1.7

<Outer>
  <h1>Hey</h1>
  <Inner />
</Outer>

Tested with above and renders fine. It would seem next.js pages need a little bit of text!

Initially asked on StackOverflow.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
ianhaggertycommented, Jan 23, 2020

Removing the google chrome extension JSON Viewer Awesome seems to have fixed this.

Parses as JSON without text, but renders markup with text.

2reactions
Iodine-commented, Mar 13, 2020

For anyone arriving here from google as I did when searching for my issue:

Removing the google chrome extension JSON Viewer Awesome seems to have fixed this.

was my issue as well. This is not a nextjs issue by any means, just a over-eager chrome extension (relevant issue)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'textContent' of null` with SSR in next.js ...
This is located under the /pages folder in a next.js app. With <Inner>Hey</Inner> , it all works fine, but change this to <Inner...
Read more >
`Uncaught TypeError: Cannot read property 'textContent' of ...
With <Inner>Hey</Inner> , it all works fine, but change this to <Inner /> and it consistently gives me Uncaught TypeError: Cannot read property...
Read more >
uncaught typeerror cannot set properties of null ... - You.com
Error "Uncaught TypeError: Cannot read properties of null (reading 'textContent')" on cmspageform.bundle.js?1.7.8.2:26 appears on console when edit a page. I ...
Read more >
View Raw - UNPKG
... (2017-12-04) ## Bug fixes * Fix bug about text filter for null ... Bug fixes * Fixed ExpandComponent.js:47 Uncaught TypeError: Cannot read...
Read more >
Updates - React PDF Viewer
Can't render certain PDF documents that contain an annotation whose ... The `Bookmarks` component provides new property that can be used to set...
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