Skip to content

Commit

Permalink
Perf opt: handleEditorChange as callback
Browse files Browse the repository at this point in the history
  • Loading branch information
sansmoraxz committed May 19, 2024
1 parent e2a3134 commit 7c948b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Binary file modified bun.lockb
Binary file not shown.
8 changes: 5 additions & 3 deletions src/CodeEditorWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Editor from "@monaco-editor/react";
import { useState } from "react";
import { useCallback, useState } from "react";
import { LogsContainer } from "./LogsContainer";
import { LuaFactory } from "wasmoon";

Expand Down Expand Up @@ -29,10 +29,11 @@ const CodeEditorWindow = ({ language }: CodeEditorWindowProps) => {

const [isRunning, setIsRunning] = useState<boolean>(false);

function handleEditorChange(value: string | undefined) {
const handleEditorChange = useCallback((value: string | undefined) => {
setSrCode(value || "");
return;
}
}, []);


async function process() {
console.clear();
Expand Down Expand Up @@ -121,3 +122,4 @@ const CodeEditorWindow = ({ language }: CodeEditorWindowProps) => {
};

export default CodeEditorWindow;

0 comments on commit 7c948b0

Please sign in to comment.