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

89
Vistas
Only 1 Active Selection on Mapped Component

I have a parent component which has a list of mapped out cards. Inside these cards, they each have their own state etc and features from an API. When selected, the card will turn blue based off this state. What I would like to do is only have 1 card active at a time, however I am not sure how to do this given that the state is in the child component. How would i feed the state back up and implement only 1 active component? I would also like to use this state in the parent component as I plan to pass back the active selection state and map it into the

Parent Component:

const JobListing = () => {


            <BottomReturnMaster>
              <FilterInterior>
                {/* BELOW IS WORKING */}
                  {
                    jobs.length > 0 && 
                    jobs.map(
                      (job) => 
                      <JobCard 
                      key={job.id} 
                      job={job}
                      
                      />)
                  }
              </FilterInterior>
              

              <JobInsightsInterior>
                <TopSectionGeneralContainer>
                  What's the details of this job?
                </TopSectionGeneralContainer>
              </JobInsightsInterior>
            </BottomReturnMaster>

  )
}

export default JobListing

And also, my state is managed in the isSelected useState. as of right now, when the card is selected it will go blue as planned. The issue is I would only like one active card at a time.

Child component:

const JobCard = ({ job }) => {

  const [open, setOpen] = useState(false)
  const [isSelected, setIsSelected] = useState(false);


  return (
    
      <CardContainer>
        {/* BELOW WORKING */}
        <CardPrimary onClick={() => setIsSelected(true)} className={isSelected ? "css-class-to-highlight-div" : undefined}>
          <CardHeader>
            <CardHeaderTopRow>
              <Typography variant = "cardheader1">
                {job.title}
              </Typography>

            </CardHeaderTopRow>
            <Typography variant = "subtitle4" color="text.secondary">
              {job.company.display_name}  
            </Typography>
          </CardHeader>

          <CardSecondary>

     

          </NewDateContainer>
          </CardSecondary>
        </CardPrimary>
      </CardContainer>
  )
}

export default JobCard

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