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

201
Vistas
What is the way to pass object short-hand as props into React component?

What is the way to pass object short-hand as props into React component to reduce redundant repetition of same named key-pairs?

Here’s a sample of something I want to avoid:

const Comp = ( {a, b, c, d} ) => {
    return (
        <div>
            <SubComp
                a={a}
                b={c}
                d={d}
            />
           <AnotherSubComp
                a={a}
                c={c}
            />
        </div>
    ) 
}; 

Something I want:

const Comp = ( {a, b, c, d} ) => {
    return (
        <div>
           <SubComp {a, c, d} />
           <AnotherSubComp {a, c} />
        </div>
    ) 
}; 

Spread operator is not an option here, and creating an intermediate object is not reducing additional code at all.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

you can use the spread operator here like this:

const Comp = ( {a, b, c, d} ) => {
    return (
        <div>
           <SubComp {...{a, c, d}} />
           <AnotherSubComp {...{a, c}} />
        </div>
    ) 
}; 
over 4 years ago · Santiago Trujillo 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