diff --git a/examples/server/public/index.html.gz b/examples/server/public/index.html.gz index a70ad56b1..9b322bbb6 100644 Binary files a/examples/server/public/index.html.gz and b/examples/server/public/index.html.gz differ diff --git a/examples/server/webui/src/components/CanvasPyInterpreter.tsx b/examples/server/webui/src/components/CanvasPyInterpreter.tsx index 6e6ea7d05..46169bbc4 100644 --- a/examples/server/webui/src/components/CanvasPyInterpreter.tsx +++ b/examples/server/webui/src/components/CanvasPyInterpreter.tsx @@ -52,22 +52,22 @@ if (StorageUtils.getConfig().pyIntepreterEnabled) { export default function CanvasPyInterpreter() { const { canvasData, setCanvasData } = useAppContext(); + const [code, setCode] = useState(canvasData?.content ?? ''); // copy to avoid direct mutation const [running, setRunning] = useState(false); const [output, setOutput] = useState(''); - const runCode = async () => { - const code = canvasData?.content; - if (!code) return; + const runCode = async (pycode: string) => { setRunning(true); setOutput('Running...'); - const out = await PyodideWrapper.run(code); + const out = await PyodideWrapper.run(pycode); setOutput(out); setRunning(false); }; // run code on mount useEffect(() => { - runCode(); + setCode(canvasData?.content ?? ''); + runCode(canvasData?.content ?? ''); // eslint-disable-next-line react-hooks/exhaustive-deps }, [canvasData?.content]); @@ -88,19 +88,14 @@ export default function CanvasPyInterpreter() {