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

93
Vistas
My menu icon doesn't get clicked whenever I place cursor on it

I've tried all methods still it doesn't work. I'm trying to build a website that has a menu icon showing up in mobile view such that when I click on it: it toggles!

import React, {useState} from 'react'
import {Link} from 'react-router-dom';
import './Navbar.css';
import { Button } from './Button';


function Navbar() {
    const {click, setClick} = useState(false);
    const {button, setButton} = useState(true);

    const handleClick = () => setClick(!click);
    const closeMobileMenu = () => setClick(false); 

    const showButton = () => {
        if(window.innerWidth <= 960){
            setButton(false);
        } else {
            setButton(true);
        }
    };

window.addEventListener("resize", showButton);

    return (
    
    
            </Link>
            <div className="menu-icon" onClick={handleClick}>
                <i className={click ? "fas fa-times" : "fas fa-bars"} /> 
            </div>
           
      
    )
}

export default Navbar
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

don't use div to handle onclick instead use input tag of submit or button tag

about 4 years ago · Juan Pablo Isaza Denunciar

0

The useState hook returns a state variable and a handler function to set the state of the variable as an array, and not as an object. Hence, the returned variable and function should be destructed as an array as opposed to object destructuring that you're currently using. Array destructuring can be done using []. E.g, If a function returns an array [1,2,3], it can be destructured and assigned to different variables in one-go using array destructuring, like : const [a,b,c] = [1,2,3]

 const [click, setClick] = useState(false);
 const [button, setButton] = useState(true); //button and setButton in an array and not object.
about 4 years ago · Juan Pablo Isaza Denunciar
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