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

297
Views
How to change props object name when it's clicked in react?

I'm creating a youtube clone using react js and i used this icon

import HomeIconfilled from '@mui/icons-material/Home';
import HomeIcon from '@mui/icons-material/HomeOutlined';

That looks like this HomeIconfilled

which gets rendered by calling this function

        <Sidebariconfunc  Icon={HomeIconfilled} Title="Home"/> 

That takes 2 parameters and reder the icon

function Sidebariconfunc({Icon,Title}) {


return (
    <div className='SidebarRow'>
           <div className='Sidebar_Icon'>
              <Icon/>
           </div>
             <div className='Slidebar_Title'>
                  {Title}
             </div>
    </div>
  )
}

How can i chane the props name to HomeIcon when i click on the icon so that it changes to this this icon HomeIcon Thamks !

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

function SidebarIcon({ActiveIcon, InactiveIcon, title, isActive}) {
  return (
    <div className='SidebarRow'>
      <div className='Sidebar_Icon'>
        {isActive ? <ActiveIcon/> : <InactiveIcon />
      </div>
      <div className='Slidebar_Title'>{Title}</div>
    </div>
  )
}

Usage:

const [isActive, setIsActive] = React.useState(false)

return (
  <a onClick={() => setIsActive(!isActive)>
    <SidebarIcon
      ActiveIcon={HomeIconfilled}
      InactiveIcon={HomeIcon}
      title='Home'
      isActive={isActive}
    />
  </a>
)
about 4 years ago · Juan Pablo Isaza Report
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!