Set focus on input

This commit is contained in:
Daniel Kluge
2021-12-16 01:15:43 +01:00
parent 2403816461
commit f7bdff1653
3 changed files with 22 additions and 8 deletions
+4 -3
View File
@@ -1,14 +1,15 @@
import { useState } from "react";
import { useRef, useState } from "react";
import REPLInput from "./REPLInput";
import REPLHistory from "./REPLHistory";
const REPL = () => {
const [history, manipulateHistory] = useState<string[]>([]);
const inputRef = useRef<HTMLInputElement>();
const onCommandExecuted = (result: string[]) => manipulateHistory(result.reverse().concat(history).slice(0, 1000));
return (<>
<REPLHistory history={history} />
<REPLInput historyCallback={onCommandExecuted} />
<REPLHistory history={history} inputRef={inputRef} />
<REPLInput historyCallback={onCommandExecuted} inputRef={inputRef} />
</>);
};