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

152
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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