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

131
Views
Passing down props through multiple components nextjs

I'm new to Next.js and have problems sharing data between components. I have three components:

//index.js
function App() {
   const options = []
    for (let i = 1; i < 101; i++) {
        options.push({
            label: i,
            value: i
        })
    }
    return (
        <>
            <Form options={options}/>
        </>
    )
}
function Form({options}) {
    return(
        <form>
            <Select options={options}/>
        </form>
    )
}
function Select({options}) {
    options = options?.map(option => {
        return <option value={option.value}>{option.label}</option>
    })
    return (
        <select>
            {...options}
        <select/>
    )
}

This is a simplified version of the code.

When I run this code I get this Error:

x Spread children are not supported in React.

This is because the options variable is not updated with the map function, when I run this code inside the select element of the Select component:

{console.log(options)}

I get an array of objects with objects that looks like this:

{
    $$typeof: Symbol(react.element),
    key: "1",
    //etc....
}

When I run this console.log() inside the Form component I get the array that I created inside the index.js file.

I feel like this has something to do with the Server-Side-Rendering in NextJS.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try, This because you are trying to do a map options data and put that into the select tag that is why select doesn't recognize your spread options data and you just need map that options data inside the select tag

function Select({options}) {
    return (
     <select>
       {options?.map((option) => {
           return <option value={option.value}> {option.label}</option>;
       })}
    </select>
  );

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!