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

189
Vistas
How to feed two children to React Component and use values?

I currently have a project in which I am feeding two values into a react component for a modal window.

One of the children is the src for the file to be displayed. Another is a string that is used to reference which Array the src is being pulled from.

I want to pass two children into the component and use them independently for different purposes.

Here is me calling the component:

       <Modal open={isOpen} onClose={() => setIsOpen(false)}>
         {accordionItems[activeSet].items[activeTrack].data}
         {activeString}
       </Modal>

Here is the inside of the component:

export default function Modal({ open, onClose, children, activeString}) {

  if (!open) return null
  return (
    <>
      <div style={MODAL_STYLES}>
        <div onClick={onClose}>Close Modal</div>
        {activeString}
        {children}      
      </div>
      </div>
    </>
  )
}

The result displays the children perfectly fine which is what is used to reference accordionItems[activeSet].items[activeTrack].data however the active string is not displayed but works okay if I only feed one parameter into the component (The active string).

Why is this?

Am I doing this correctly? I need to be able to access both!

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want pass activeString is a props. Pass it inline with Modal:

<Modal open={isOpen} onClose={() => setIsOpen(false)} activeString={activeString}>
  {accordionItems[activeSet].items[activeTrack].data} // => childrend
</Modal>
about 4 years ago · Juan Pablo Isaza 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