A little improvement on move handling
This commit is contained in:
@@ -9,8 +9,9 @@ import { json } from "@codemirror/lang-json";
|
||||
import { python } from "@codemirror/lang-python";
|
||||
import { java } from "@codemirror/lang-java";
|
||||
import { useEffect, useState } from "react";
|
||||
import useAction from "@/hook/use-action";
|
||||
import useAction, { useActionOnce } from "@/hook/use-action";
|
||||
import { getLiveRunMoves } from "@/modules/live-run/actions";
|
||||
import { LiveRun } from "@/modules/live-run/types";
|
||||
|
||||
type Language =
|
||||
| "javascript"
|
||||
@@ -50,9 +51,9 @@ type Move = {
|
||||
};
|
||||
};
|
||||
|
||||
export default function Editor() {
|
||||
export default function Editor({ run }: { run: LiveRun | null }) {
|
||||
const [editorView, setEditorView] = useState<EditorView>();
|
||||
const [moves] = useAction<Move[]>(getLiveRunMoves);
|
||||
const [moves] = useActionOnce<Move[]>(getLiveRunMoves, [run]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!editorView || !moves) return;
|
||||
|
||||
@@ -82,7 +82,7 @@ export default function Run() {
|
||||
<File size={16} /> myfile.js
|
||||
</header>
|
||||
<div className="flex-1 pt-3 pb-4 md:pb-5 w-full h-full">
|
||||
<Editor />
|
||||
<Editor run={run} />
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
Reference in New Issue
Block a user