3

I basically want to do this: importMDX(`../${variable}.mdx`);

But the only thing that works is this: importMDX('../filename.mdx');

Is using variables in the importMDX() function not supported at all or am i missing something? I've looked throught the documentation for MDX but they give no examples of doing what i want to do, but they don't state that this is not supported either.

Documentation: https://www.npmjs.com/package/mdx.macro

I basically want to do what they do in their example but using a variable as/in the filepath

import { importMDX } from './mdx.macro'

const myVariable = './my-document.mdx'; //I want to do this
const MyDocument = React.lazy(() => importMDX(myVariable))//Here

ReactDOM.render(
  <React.Suspense fallback={<div>Loading...</div>}>
    <MyDocument />
  </React.Suspense>,
  document.getElementById('root')
)
MoazRub
  • 2,881
  • 2
  • 10
  • 20
Ferben
  • 31
  • 3

0 Answers0