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

139
Views
assign values to object via loop and then make it object again

Idea is to create an Component with a child which could be any component, so i need to assign the props to this Component.

I try to do it in a loop, because i don't know how many props there should be

//Array of objects which i wanna render
{array?.[i] && (
    <Component
        {...Object.keys(component.props)?.map(prop => ({
            [prop]: array?.[i]?.[prop]
        }))}
    />
)}

but as result in inspector i got something like..

props
0:{prop1: "prop1"}
1:{prop2: "prop2"}
2:{prop3: "prop3"}

But i wan't to look it like this

prop1: "prop1",
prop2: "prop2"
prop3: "prop3"
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

burned out a bit

all i tried to do is like

<Component
    {...Object.keys(component.props)?.reduce((acc: { [key: string]: any }, curr) => {
    acc[curr] = array?.[i]?.[curr]
    return acc
    }, {})}
/>
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!