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

85
Vistas
How can I pass props to inner React component using functional approach

I am using react with the following functional approach

const Divider: React.FunctionComponent = ({children}) => (
   <div>
      // I want to use color props here of Card
      divider
      {children}
   </div>
);

const Card: React.FunctionComponent = ({children, color}) => {
 const color = props.color

 return(
   <div>
      card
      {children}
   </div>
 )}

Card.Divider = Divider;

and I call these components as following

<Card color="red">
 <Card.Divider>
  Any text
 <Card.Divider/>
<Card />

The problem is: How can I get the color props in the Divider component

PS: I don't want to repeat props passing again for divider like following

<Card color="red">
 <Card.Divider color="red">
  Any text
 <Card.Divider/>
<Card />

What I want is the following approach and can still able to use color props in Divider component, how can I do that

<Card color="red">
 <Card.Divider>
  Any text
 <Card.Divider/>
<Card />
about 4 years ago · Juan Pablo Isaza
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