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

124
Vistas
MDX applies styles to wrong elements (MDX in next-mdx-remote)

I have two components, ItemA & ItemB:

ItemA:

const ItemA = ({ color }) => {

    return (
            <div
                style={{
                    color: color
                }}>
                Item A
            </div>
    );
};

ItemB:

const ItemB = () => {
    return (
        <div>
            <div>Item B</div>
        </div>
    );
};

I use these in MDX files with next-mdx-remote. ItemA is to be used inline, ItemB outside of any text:

These <ItemA color="red" /> <ItemA color="blue" /> are two item-A components, used inline, that is, within text.  Now let's have a look at the Item-Bs:

<ItemB />
<ItemB />
<ItemB />

I would now expect my ItemAs to be coloured (red & blue), and my ItemBs to be black / unstyled. However, my ItemBs are taking over the styles of my ItemAs, in consecutive order:

enter image description here

When I move the ItemAs above the text (and do not use them inline) things are working fine:

<ItemA color="red" />
<ItemA color="blue" />

These <ItemA color="red" /> <ItemA color="blue" /> are two item-A components, used inline, that is, within text.  Now let's have a look at the Item-Bs:

<ItemB />
<ItemB />
<ItemB />

enter image description here

I have also noticed, that when I turn the outmost div in ItemA into a span, things are working as expected again, even when ItemA is used inline:

enter image description here

However, I have no idea why and what the culprit might be? Is it next-mdx-remote? Or just mdx in general?

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