Cannot read property 'className' of undefined (gatsby-transformer-remark v4+)
See original GitHub issueHi guys,
Description
After upgrading the gatsby-transformer-remark from v3 to v4, blog queries stopped working. Gatsby throws an error:
success run static queries - 1.053s - 8/8 7.60/s
ERROR #85901 GRAPHQL
There was an error in your GraphQL query:
Cannot read property 'className' of undefined
1 | query homer007ProjectsociussrctemplatesblogPostJs1196972383($slug: String!) {
2 | markdownRemark(fields: {slug: {eq: $slug}}) {
> 3 | html
| ^
4 | frontmatter {
5 | title
6 | date(formatString: "DD MMMM, YYYY")
7 | author
8 | }
9 | excerpt
10 | }
11 | }
12 |
File path: /home/r007/Projects/ocius/src/templates/blogPost.js
Url path: /blog/ocius-successfully-completes-seatrials/
Plugin: none
TypeError: Cannot read property 'className' of undefined
- list.js:25 list
[ocius]/[mdast-util-to-hast]/lib/handlers/list.js:25:31
- one.js:37 one
[ocius]/[mdast-util-to-hast]/lib/one.js:37:51
- all.js:16 all
[ocius]/[mdast-util-to-hast]/lib/all.js:16:14
- paragraph.js:8 paragraph
[ocius]/[mdast-util-to-hast]/lib/handlers/paragraph.js:8:23
- one.js:37 one
[ocius]/[mdast-util-to-hast]/lib/one.js:37:51
- all.js:16 all
[ocius]/[mdast-util-to-hast]/lib/all.js:16:14
- root.js:10 root
[ocius]/[mdast-util-to-hast]/lib/handlers/root.js:10:41
- one.js:37 one
[ocius]/[mdast-util-to-hast]/lib/one.js:37:51
- index.js:122 toHast
[ocius]/[mdast-util-to-hast]/lib/index.js:122:14
- extend-node-type.js:343 markdownASTToHTMLAst
[ocius]/[gatsby-transformer-remark]/extend-node-type.js:343:14
- extend-node-type.js:359 getHTMLAst
[ocius]/[gatsby-transformer-remark]/extend-node-type.js:359:25
- runMicrotasks
- task_queues.js:58 runNextTicks
internal/process/task_queues.js:58:5
- timers.js:434 processImmediate
internal/timers.js:434:9
- extend-node-type.js:372 getHTML
[ocius]/[gatsby-transformer-remark]/extend-node-type.js:372:21
- async Promise.all
not finished run page queries - 5.331s
After downgrade back to v3.2.0, the issue is fixed.
Steps to reproduce
git clone https://github.com/ocius/website ociuscd ociusgit checkout redesign-stage-1npm install gatsby-transformer-remark --savegatsby build
Environment
System:
OS: Linux 5.8 Ubuntu 20.10 (Groovy Gorilla)
CPU: (8) x64 Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.0/bin/yarn
npm: 7.11.2 - ~/.nvm/versions/node/v14.16.0/bin/npm
Languages:
Python: 2.7.18 - /usr/bin/python
Browsers:
Chrome: 87.0.4280.141
Firefox: 88.0
npmPackages:
gatsby: ^3.4.0 => 3.4.0
gatsby-awesome-pagination: ^0.3.8 => 0.3.8
gatsby-background-image: ^1.5.3 => 1.5.3
gatsby-plugin-advanced-sitemap: ^1.6.0 => 1.6.0
gatsby-plugin-gtag: ^1.0.13 => 1.0.13
gatsby-plugin-image: ^1.4.0 => 1.4.0
gatsby-plugin-mailchimp: ^5.2.2 => 5.2.2
gatsby-plugin-optimize-svgs: ^1.0.5 => 1.0.5
gatsby-plugin-react-helmet: ^4.4.0 => 4.4.0
gatsby-plugin-sharp: ^3.4.0 => 3.4.0
gatsby-plugin-styled-components: ^4.4.0 => 4.4.0
gatsby-remark-copy-linked-files: ^4.1.0 => 4.1.0
gatsby-remark-images: ^5.1.0 => 5.1.0
gatsby-remark-images-grid: ^1.1.2 => 1.1.2
gatsby-remark-responsive-iframe: ^4.1.0 => 4.1.0
gatsby-source-filesystem: ^3.4.0 => 3.4.0
gatsby-transformer-remark: ^3.2.0 => 3.2.0
gatsby-transformer-sharp: ^3.4.0 => 3.4.0
gatsby-transformer-yaml: ^3.4.0 => 3.4.0
npmGlobalPackages:
gatsby-cli: 3.4.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Uncaught TypeError: Cannot read property 'className' of ...
... suppose to create the slides but it give me this error Uncaught TypeError: Cannot read property 'className' of undefined. but when i...
Read more >Cannot read property 'className' of undefined #2092 - GitHub
When I create a select control without any options and with width: auto, I get the following error during initialization: Uncaught ...
Read more >Grid Cell Styler - Cannot read property className of null
Hello! I am getting a “Cannot read property 'className' of null” error when trying to use the Grid Cell Styler widget from the...
Read more >Uncaught TypeError: Cannot read property of null - iDiallo
This will result in Uncaught TypeError: Cannot read property 'value' of null . The reason will be that the element with id input...
Read more >Problem with Javascript Tabs (cannot read property ...
... some javascript and CSS, but when I try to highlight the active tab it throws me an error: cannot read property className...
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 Free
Top 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

I also use
gatsby-remark-images-gridand faced same problem around a month ago when i upgraded to gatsby@3.3.0 i fixed it by changegatsby-remark-images-gridto local plugins and modify itsindex.jsfrom this:
to this:
notice the
type, changed fromlisttoparentI haven’t notified @cedricdelpoux yet because frankly i am not really sure about this fix. But until now
gatsby-remark-images-gridin my project works fine with the latestremark (micromark)It seems that the new
remark (micromark)is more strict? (i don’t know the best term for this), if themdastnode type islistit expectshNameto beulorolor i don’t know… can anybody tell me is there any documentation aboutmicromarkthat mention this? i haven’t found it yet.Seems like the original gatsby-remark-images-grid repository abandoned. No reply from author himself 😟 So I forked the repository. It looks like I’m a maintainer now.
Feel free to use it. Also, I published package on NPM:
Changes:
@hendra-go thank you for your fix!