Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 752 Bytes

File metadata and controls

37 lines (24 loc) · 752 Bytes

tinky


tinky / useStdin

Function: useStdin()

useStdin(): StdinProps

useStdin is a React hook that exposes the stdin stream and related utilities.

Returns

StdinProps

The stdin context containing the stdin stream, setRawMode function, and isRawModeSupported flag.

Example

import { useStdin } from "tinky";

function InputComponent() {
  const { stdin, setRawMode, isRawModeSupported } = useStdin();

  useEffect(() => {
    if (isRawModeSupported) {
      setRawMode(true);
      return () => setRawMode(false);
    }
  }, [setRawMode, isRawModeSupported]);

  return <Text>Listening for input...</Text>;
}