Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!