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.

NavbarWrapper throws "Cannot read properties of null (reading 'clientHeight')"

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

I am trying to build own custom navbar, but the wrapper always throws an error even with empty component like this

import React from "react";
import Navbar from "@theme-original/Navbar";

export default function NavbarWrapper(props) {
  return <></>;
}

When you go to to /docs/intro, it throws Cannot read properties of null (reading 'clientHeight')

https://codesandbox.io/s/restless-forest-9qmniw

Reproducible demo

No response

Steps to reproduce

  1. Create NavbarWrapper with npm run swizzle @docusaurus/theme-classic Navbar -- --wrap
  2. Remove default Navbar (You may just return <></>)
  3. Go to /docs/intro

Expected behavior

It should display the custom Navbar

Actual behavior

it throws Cannot read properties of null (reading 'clientHeight')

Your environment

Self-service

  • I’d be willing to fix this bug myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
Josh-Cenacommented, May 26, 2022

Thanks for pointing that out @slorber

I created this site when I didn’t even know React (I Googled for an hour to fix some date-fns version mismatch). I’ll update that when I got time to; haven’t touched it in a while now.

1reaction
canmingircommented, May 26, 2022

Nice, it worked with having a wrapper like below. I was trying to use MUI’s AppBar as a header.

return (
    <span className={"navbar"}>
      <AppBar>...</AppBar>
    </span>
  );
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'clientHeight' of Null in JS
The "Cannot read property 'clientHeight' of null" error occurs for 2 reasons: Accessing the clientHeight property on a null value. Placing the JS...
Read more >
Uncaught TypeError: Cannot read property 'clientHeight' of null
I don't know why it can't find the height. Any help would be appreciated.
Read more >
Cannot read property 'clientHeight' of null · Issue #1572 - GitHub
When I open page with grid and goes back immediately to prev page I have a error message "Uncaught TypeError: Cannot read property...
Read more >
cannot read properties of null (reading 'command') - You.com
Create NavbarWrapper with npm run swizzle @docusaurus/theme-classic Navbar -- --wrap ... it throws Cannot read properties of null (reading 'clientHeight') ...
Read more >
HTML DOM Element clientHeight Property - W3Schools
Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant ......
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