Closed kevinsullivan closed 4 years ago
Hey @kevinsullivan, it's unfortunate your bumping into an issue with gatsby-plugin-mdx
. I'd love to help you get to the bottom of this.
Is there any chance you could provide a minimal reproduction (either a GitHub repo or CodeSandbox)? It would make it much quicker for us to debug. The compiled code from the MDX query appears to be correctly formed.
Also, can you provide the implementation for your Lean component?
Thanks! :pray::pray:
@johno I'm getting a javascript string for data.mdx.body
too!
I have been able to reproduce it with a gatsby-node.js
implementation to generate pages from a content
directory, from the hello-world starter.
Jumped on this issue because it's the only place I could find function _extends()
and didn't know what it was. I missed out <MDXRenderer>
wrapper when migrating from remark -> mdx.
Please re-open/request to reopen when you got a reproduction. Thanks!
Summary
I'm trying to use MDXRenderer to render the data.mdx.body values from the data values returned by a page query (by slug). The query appears to be working. The data.mdx.body value being passed to Template, when printed by applying JSON.stringify reveals JS code seemingly compiled from my mdx file along with other stuff. I assume that this code is a valid mdx body. Yet I get an error: "Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object." I can provide any other info that might be needed.
Relevant information
For starters here's my template file.
Now if I substitute that commented-out stringify call, to return a stringified version of data.mdx.body instead of applying MDX Provider and Renderer, here's what's displayed:
Here's a stack dump from the browser:
This is what I'm assuming (but am probably wrong about) is a correct mdx body that MDXRenderer should be rendering correctly. Suggestions welcome.
Environment (if relevant)
System: OS: macOS 10.15.1 CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 13.5.0 - /usr/local/bin/node Yarn: 1.21.1 - /usr/local/bin/yarn npm: 6.13.4 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/local/bin/python Browsers: Chrome: 79.0.3945.88 Firefox: 71.0 Safari: 13.0.3 npmPackages: gatsby: ^2.18.6 => 2.18.17 gatsby-cli: ^2.8.22 => 2.8.22 gatsby-image: ^2.2.34 => 2.2.37 gatsby-plugin-antd: ^2.1.0 => 2.1.0 gatsby-plugin-catch-links: ^2.1.19 => 2.1.21 gatsby-plugin-emotion: ^4.1.16 => 4.1.18 gatsby-plugin-eslint: ^2.0.8 => 2.0.8 gatsby-plugin-feed-mdx: ^1.0.0 => 1.0.0 gatsby-plugin-manifest: ^2.2.34 => 2.2.34 gatsby-plugin-mdx: ^1.0.64 => 1.0.64 gatsby-plugin-nprogress: ^2.1.15 => 2.1.17 gatsby-plugin-offline: ^3.0.30 => 3.0.30 gatsby-plugin-react-helmet: ^3.1.16 => 3.1.18 gatsby-plugin-react-next: ^1.0.11 => 1.0.11 gatsby-plugin-reason: ^2.0.1 => 2.0.1 gatsby-plugin-sharp: ^2.3.4 => 2.3.10 gatsby-plugin-sitemap: ^2.2.24 => 2.2.24 gatsby-plugin-styled-components: ^3.1.16 => 3.1.16 gatsby-plugin-theme-ui: ^0.2.53 => 0.2.53 gatsby-plugin-tslint: ^0.0.2 => 0.0.2 gatsby-plugin-typescript: ^2.1.23 => 2.1.23 gatsby-plugin-typography: ^2.3.18 => 2.3.20 gatsby-remark-copy-linked-files: ^2.1.33 => 2.1.33 gatsby-remark-external-links: ^0.0.4 => 0.0.4 gatsby-remark-images: ^3.1.34 => 3.1.39 gatsby-remark-katex: ^3.1.20 => 3.1.20 gatsby-remark-mathjax: ^1.0.0 => 1.0.0 gatsby-remark-prismjs: ^3.3.25 => 3.3.28 gatsby-remark-responsive-iframe: ^2.2.30 => 2.2.30 gatsby-remark-slug: ^0.1.0 => 0.1.0 gatsby-remark-smartypants: ^2.1.19 => 2.1.19 gatsby-source-filesystem: ^2.1.39 => 2.1.43 gatsby-source-graphql: ^2.1.29 => 2.1.29 gatsby-transformer-remark: ^2.6.45 => 2.6.45 gatsby-transformer-sharp: ^2.3.6 => 2.3.9 npmGlobalPackages: gatsby-cli: 2.8.22
File contents (if changed)
gatsby-config.js
: N/Apackage.json
: N/Agatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/A