Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

276
Visualizações
¿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 Respostas
Responde à pergunta

0

Try to use classnames instead of styling with id

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda