Home / Function/ useKeyCommand() — react Function Reference

useKeyCommand() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  2df99129_7d85_b9e7_b37a_6892433084a3["useKeyCommand()"]
  f5dfff46_cb67_3fb9_9732_9da58697cb8e["capture-ref-for-later-mutation.tsx"]
  2df99129_7d85_b9e7_b37a_6892433084a3 -->|defined in| f5dfff46_cb67_3fb9_9732_9da58697cb8e
  style 2df99129_7d85_b9e7_b37a_6892433084a3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capture-ref-for-later-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/capture-ref-for-later-mutation.tsx.
Where is useKeyCommand() defined?
useKeyCommand() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capture-ref-for-later-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