Home / Function/ useKeyCommand() — react Function Reference

useKeyCommand() — react Function Reference

Architecture documentation for the useKeyCommand() function in error.capture-ref-for-mutation.tsx from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  8603951d_36b0_1fe4_0f20_3a7cafa036df["useKeyCommand()"]
  de0ba1c7_0094_00e5_5d6e_855bdcbc8e00["error.capture-ref-for-mutation.tsx"]
  8603951d_36b0_1fe4_0f20_3a7cafa036df -->|defined in| de0ba1c7_0094_00e5_5d6e_855bdcbc8e00
  style 8603951d_36b0_1fe4_0f20_3a7cafa036df fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.capture-ref-for-mutation.tsx lines 4–18

function useKeyCommand() {
  const currentPosition = useRef(0);
  const handleKey = direction => () => {
    const position = currentPosition.current;
    const nextPosition = direction === 'left' ? addOne(position) : position;
    currentPosition.current = nextPosition;
  };
  const moveLeft = {
    handler: handleKey('left')(),
  };
  const moveRight = {
    handler: handleKey('right')(),
  };
  return [moveLeft, moveRight];
}

Subdomains

Frequently Asked Questions

What does useKeyCommand() do?
useKeyCommand() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.capture-ref-for-mutation.tsx.
Where is useKeyCommand() defined?
useKeyCommand() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.capture-ref-for-mutation.tsx at line 4.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free