gatsby: navigation.js:173 Uncaught TypeError

Updated my packages today and started getting this error when i click a link on my webpage.

navigation.js:173 Uncaught TypeError: Cannot read property 'getElementsByTagName' of null
    at navigation.js:173

  170 | if (document.title) {
  171 |   pageName = document.title
  172 | }
> 173 | const pageHeadings = document
  174 |   .getElementById(`gatsby-focus-wrapper`)
  175 |   .getElementsByTagName(`h1`)
  176 | if (pageHeadings && pageHeadings.length) {

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 21
  • Comments: 26 (7 by maintainers)

Most upvoted comments

Fixed and published in gatsby@2.19.12

Apologies for this.

Fix incoming

Same here

Having the same issue, “gatsby”: “^2.19.19”.

Edit: I fixed it. My components filename was “Search.js” and route was navigate(“/search”). Renamed my file to search.js and it started working.

Same error for me, I have 2.19.12 and @reach/router: 1.2.1, blown away node_modules and everything else associated with my project and the error is still occurring.

checked for both reach/router and gatsby versions in the dependencies, then removed node_modules and re-installed

still getting the error

Same issue. Was working fine until I start using MDXRenderer (gatsby-plugin-mdx)

I seem to be getting this exact issue even after updating Gatsby to 2.19.12

Yea same issue for me, interestingly my project works fine until I start using Gatsby Image, then the problem occurs on my homepage only /pages/index