Code Room
Code reviewHardcr-g390
Subject Stale closureLevel Senior–Staff~22 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this React TypeScript keyboard-shortcut hook.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewtsx
function useUndoShortcut(history: string[], onUndo: () => void) {  useEffect(() => {    const onKey = (e: KeyboardEvent) => {      if (e.key === 'z' && (e.metaKey || e.ctrlKey) && history.length > 0) {        onUndo();      }    };    window.addEventListener('keydown', onKey);    return () => window.removeEventListener('keydown', onKey);  }, []);}
Run or narrate your approach, then ask the coach.