Skip to content

refactor: Fix React Compiler hint in KeyboardShortcut #1073

Description

@frankieyan

Part of #1066.

  • File: src/components/keyboard-shortcut/keyboard-shortcut.tsx
  • Violation: LogicalExpression cannot be safely reordered (BuildHIR::lowerReorderableExpression, Hint, line 122): the isMac default parameter value (navigator.platform?.toUpperCase().includes('MAC') ?? false).

Steps

  1. Reproduce and confirm. Hint severity, but the component is still not memoized (confirmed in the compiled output).
  2. Fix per #default-parameters-for-props: move the navigator.platform check out of the default-parameter position into the body so the expression is reorderable. Preserve the KeyboardShortcut.setTranslateKey public API.
  3. Confirm the count dropped; let the hook update the record file.
  4. Verify memoization in the compiled output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions