NavbarWrapper throws "Cannot read properties of null (reading 'clientHeight')"
See original GitHub issueHave you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clear
oryarn 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
- Create NavbarWrapper with
npm run swizzle @docusaurus/theme-classic Navbar -- --wrap
- Remove default Navbar (You may just return
<></>
) - 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
- Public source code: https://github.com/NucleoidJS/nucleoid.com/tree/docusaurus
- Public site URL: https://nucleoid.com
- Docusaurus version used: 2.0.0-beta.20
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome 101
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): Windows 10
Self-service
- I’d be willing to fix this bug myself.
Issue Analytics
- State:
- Created a year ago
- Comments:9
Top 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 >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 FreeTop 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
Top GitHub Comments
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.
Nice, it worked with having a wrapper like below. I was trying to use MUI’s AppBar as a header.