codev / src /ink /hooks /use-stdout.ts
chenbhao's picture
feat: add useStdout and useIsScreenReaderEnabled hooks for ink-picture
f73174f
Raw
History Blame Contribute Delete
385 Bytes
import { useContext } from 'react'
import StdoutContext from '../components/StdoutContext.js'
/**
* A React hook that returns the stdout stream where Ink renders your app,
* plus a `write` function for emitting raw data to stdout outside of Ink's
* normal render loop (e.g. for inline image protocols).
*/
export default function useStdout() {
return useContext(StdoutContext)
}