first of many performance improvements: no unnecessary TextSVG re-renders - more to follow

This commit is contained in:
Joeri Exelmans 2025-10-23 21:22:28 +02:00
parent af60e811fc
commit 0fc3775a11
14 changed files with 116 additions and 74 deletions

View file

@ -1,4 +1,4 @@
import { ReactElement, useEffect, useMemo, useRef, useState } from "react";
import { ReactElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { emptyStatechart, Statechart, Transition } from "../statecharts/abstract_syntax";
import { handleInputEvent, initialize, RuntimeError } from "../statecharts/interpreter";
@ -85,9 +85,9 @@ export function App() {
const plant = plants.find(([pn, p]) => pn === plantName)![1];
const editorState = historyState.current;
const setEditorState = (cb: (value: VisualEditorState) => VisualEditorState) => {
const setEditorState = useCallback((cb: (value: VisualEditorState) => VisualEditorState) => {
setHistoryState(historyState => ({...historyState, current: cb(historyState.current)}));
}
}, [setHistoryState]);
const refRightSideBar = useRef<HTMLDivElement>(null);