Skip to content

Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase') #64

@SutuSebastian

Description

@SutuSebastian

Describe the bug
Console error when component gets unmounted.

To Reproduce
Steps to reproduce the behavior:

  1. use useKey() / useKeyCombo()
  2. unmount the component
  3. See error

Expected behavior
No errors.

Additional context

Using a custom component:

import {
  bindKey,
  bindKeyCombo,
  unbindKey,
  unbindKeyCombo,
} from "@rwh/keystrokes";
import { useEffect } from "react";

export function useKey(...args: Parameters<typeof bindKey>) {
  useEffect(() => {
    bindKey(...args);

    return () => unbindKey(...args);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, args);
}

export function useKeyCombo(...args: Parameters<typeof bindKeyCombo>) {
  useEffect(() => {
    bindKeyCombo(...args);

    return () => unbindKeyCombo(...args);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, args);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions