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

154
Visualizações
How to pass as a props an array of String and JSX with NextJs?

i passed as a props an array of strings an JSX but there is an error message "Missing "key" prop for element in arrayeslintreact/jsx-key "

<Sec1Header
    
      MainText={[
        "Your ",
        <span className='text-red-400'>
          Trusted
        </span>,
        " Development Partner",
      ]}
  
    />

I'm doing all of that to just try to color the text "Trusted" with different colors and not change the div dynamic

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You're passing your props in correctly, it's the react/jsx-key ESLint rule that's generating that message. You just need to add a key prop to that <span> tag:

<Sec1Header
  MainText={[
    "Your ",
    <span key="coloredText" className="text-red-400">
      Trusted
    </span>,
    " Development Partner",
  ]}
/>

Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array to give the elements a stable identity...

https://reactjs.org/docs/lists-and-keys.html#keys

But as one comment suggested, I would also convert that colored text into its own separate child component.

about 4 years ago · Juan Pablo Isaza Relatório
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