React Hook doesnt update the value

  button, javascript, react-hooks, reactjs

Im using a React´s hook to stablish a value according with wich button has been clicked, but the setBotonPresionado doesnt update the value, the console log shows that, the value is empty wich is the initial value

const [desactivarComprar, setDesactivarComprar] = useState(true);
const [desactivarPrimerBoton, setDesactivarPrimerBoton] = useState(false);
const [desactivarSegundoBoton, setDesactivarSegundoBoton] = useState(false);
const [desactivarTercerBoton, setDesactivarTercerBoton] = useState(false);
const [botonPresionado, setBotonPresionado] = useState('');
  
const onChangeBotonBronze = () => {      
        setBotonPresionado('bronze');
        console.log(botonPresionado);
        activarYDesactivar(); 
};

boton presionado means pressed button

Source: Ask Javascript Questions

LEAVE A COMMENT