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

247
Vistas
I want this code to undo/redo user action which worked as wanted but after the undo/redo is completed and I undo/redo again I get an error

The error state > Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'undo') History.undo

please how can I implement a code to undoDisable and redoDisabled that would make my code stop running once the last undo/redo have been triggered so I don't get the error again**

below is my code that handles the undo and redo action

  const handleUndokey = async (e: KeyboardEvent) => {
    const zKey = 'z';
    if (e.ctrlKey && e.key === zKey) {
      designer.clearSelectedElements();
      await history.undo();
      dispatch(updateDesigner(designer));
      saveDesigner();
    }
  };

  useEffect(() => {
    document.addEventListener('keydown', handleUndokey);
    return () => {
      document.removeEventListener('keydown', handleUndokey);
    };
  }, []);

  const handleRedoKey = async (e: KeyboardEvent) => {
    const yKey = 'y';
    if (e.ctrlKey && e.key === yKey) {
      designer.clearSelectedElements();
      await history.redo();
      dispatch(updateDesigner(designer));
      saveDesigner();
    }
  };

  useEffect(() => {
    document.addEventListener('keydown', handleRedoKey);
    return () => {
      document.removeEventListener('keydown', handleRedoKey);
    };
  }, []);
about 4 years ago · Juan Pablo Isaza
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