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

272
Views
¿why my useSatte toggle is not changing className, dinamic render?

I made a boolean useState fro toggle, so i putted the toggle funciton on a Onclick={} placed on the hamburguer menu and then made a dinamic change in the className based on the boolen but although the toggle is working good when i click on the hambuerguer menu, the navLinks which show and hide are just doing nothing so i was wondering why the className is not doing what its supposed to. Here is my code, any help will be really appreciated.

 const [showNav, setShowNav] = useState(false) 

  const openMenu = () =>{
    setShowNav(!showNav)

    console.log(showNav)
  }

 <nav className='app__nav' id={showNav? 'hidden':''} >
        <img className="nav__close-btn" src={closeButton} alt="close-menu"/>
          <ul>            
            <li><Link className="nav__link" to='#'>Alumnos</Link></li>
            <li><Link className="nav__link" to='#'>Voluntarios</Link></li>
            <li><Link className="nav__link" to='#'>Nosotros</Link></li>           
          </ul>
        </nav>

And here is the css

.app__header .app__nav{
  position: fixed;
  right: 0;
  top: 0;
  background-color:white;
  height: 100vh;
  width: 50%;
  z-index: 2;
  text-transform:uppercase;
  transform: translateX(100%);  
  transition: 0.5s ease-in-out;
}

 .app__header .app__nav #hidden{
  transform: translateX(0%);  
  /* transition: 0.5s ease-in-out; */
}

Hope you can tell me whats wrong, thank you!

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

0

Try to use classnames instead of styling with id

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!