Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
React not rendering an mdxjs file

I am trying to create an addon for storybook that adds a tab to the top of the page, I have it working except that I cannot get it to render an MDX file in the preview area.

The Addon file contains the following JavaScript:

import { MDXProvider } from '@mdx-js/react';
import { addons, types } from '@storybook/addons';
import React from 'react';


addons.register('my-api', (api) => {
  addons.add('my-api/tab', {
    render: () => {
      const Page = api.getCurrentStoryData()?.parameters?.api?.page;

      console.log(
        'md', 
        Page, 
        typeof Page === 'function' ? Page() : undefined
      );

      return (
        <div>
          {
            typeof Page === 'undefined' ?
              <h2>No API setup for this Story.</h2> :
              <MDXProvider><Page /></MDXProvider>
          }
        </div>
      );
    },
  });
});

The above React was taken from this example. My console log outputs the following:

md ƒ result() {
        // eslint-disable-next-line no-eval
        var f = eval("(".concat(sourceSanitized, ")"));
        return f.apply(void 0, arguments);
      } undefined

In the story that I am setting this up with, the page data with looks like below. I import the api and pass it to the parameters. From there the addon gets the data and and should render the file.

import Api from './button.api.mdx';

export default {
  parameters: {
    api: { page: Api }
  }
} as Meta;

I am also getting the following error message:

Uncaught Error: MDXContent(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

I have also tried removing <MDXProvider> and just did <Page /> which also gives me the same error.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda