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

87
Views
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
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!