CODEBASE: Add custom useRerender hook (#359)

This commit is contained in:
Snarling
2023-02-11 13:22:55 -05:00
committed by GitHub
parent b4074328ec
commit 6a6043c509
46 changed files with 137 additions and 357 deletions

View File

@@ -45,6 +45,7 @@ import { Modal } from "../../ui/React/Modal";
import libSource from "!!raw-loader!../NetscriptDefinitions.d.ts";
import { TextField, Tooltip } from "@mui/material";
import { useRerender } from "../../ui/React/hooks";
interface IProps {
// Map of filename -> code
@@ -106,10 +107,7 @@ let currentScript: OpenScript | null = null;
// Called every time script editor is opened
export function Root(props: IProps): React.ReactElement {
const setRerender = useState(false)[1];
function rerender(): void {
setRerender((o) => !o);
}
const rerender = useRerender();
const editorRef = useRef<IStandaloneCodeEditor | null>(null);
const monacoRef = useRef<Monaco | null>(null);
const vimStatusRef = useRef<HTMLElement>(null);