Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda