hermes / ui-tui /src /hooks /useInputHistory.ts
haochengsama's picture
Add files using upload-large-folder tool
04d8658 verified
Raw
History Blame Contribute Delete
398 Bytes
import { useRef, useState } from 'react'
import * as inputHistory from '../lib/history.js'
export function useInputHistory() {
const historyRef = useRef<string[]>(inputHistory.load())
const [historyIdx, setHistoryIdx] = useState<number | null>(null)
const historyDraftRef = useRef('')
return { historyRef, historyIdx, setHistoryIdx, historyDraftRef, pushHistory: inputHistory.append }
}