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.

Need to upgrade to v1 of "@mdx-js/mdx" to render JSX mid-line

See original GitHub issue

Currently JSX does not work in the middle of components with mdx-loader, because it is using an old version of @mdx-js/mdx.

This works

<span style={{ color: "red }}>I'm red</span>

But this doesn’t, it breaks the build 😢

I'm a paragraph in markdown <span style={{ color: "red" ]}>And I'm red</span>

This should be supported with mdx version 1

Upgrading to v1 of @mdx-js/mdx will fix this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
adueckcommented, May 30, 2019

Ouch… but then this breaks something else. 😞 The files all load fine, front matter and everything comes through with the updated updated @mdx-js/mdx but then when you try to render the component from the import in React this happens:

Using my experimental updated forked version of mdx-loader:

import React from 'react';
/* eslint-disable import/no-webpack-loader-syntax */
import About from '!babel-loader!updated-mdx-loader!./content/intro/about.mdx';

function App() {
    return (
        <About />
    )
}

Error Message:

ReferenceError: mdx is not defined
MDXContent
http://localhost:3000/static/js/main.chunk.js:1260:3

...

> 1260 | return mdx(MDXLayout, Object.assign({}, layoutProps, props, {
       | ^  1261 |   components: components,
  1262 |   mdxType: "MDXLayout",
  1263 |   __source: { 
0reactions
adueckcommented, May 30, 2019

Ok I figured it out! 😄

With the new result that comes from @mdx-js/mdx v. 1, you need to include the following:

import { mdx } from '@mdx-js/react'

Now with my updated PR it works great. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Upgrade to React 18
Updates to Client Rendering APIs. When you first install React 18, you will see a warning in the console: ReactDOM.render is no longer...
Read more >
Migrating your React Router App to Remix
Migrating your React Router app to Remix can be done all at once or in stages. This guide will walk you through an...
Read more >
ReactDOM.render is no longer supported in React 18 - Stack ...
renderToNodeStream has been deprecated. To resolve it, you can either revert to a previous version of React or update your index.js file to ......
Read more >
Use Office UI Fabric React components in your SharePoint ...
In the case where you want to upgrade an SPFx v1.8 project to Office UI Fabric React v6, you'll also need to upgrade...
Read more >
Use the key prop when Rendering a List with React | egghead.io
JSX is merely JavaScript and to render a list you can use the array method .map to map ... The Beginner's Guide to...
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