memoize parsed text labels
This commit is contained in:
parent
529ad1d4bd
commit
65b6a343d1
3 changed files with 9 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { Dispatch, ReactElement, SetStateAction, useState, KeyboardEvent, useEffect, useRef } from "react";
|
||||
|
||||
import { parse as parseLabel } from "../statecharts/label_parser";
|
||||
import { cachedParseLabel } from "@/statecharts/parser";
|
||||
|
||||
export function TextDialog(props: {setModal: Dispatch<SetStateAction<ReactElement|null>>, text: string, done: (newText: string|undefined) => void}) {
|
||||
const [text, setText] = useState(props.text);
|
||||
|
|
@ -22,7 +22,7 @@ export function TextDialog(props: {setModal: Dispatch<SetStateAction<ReactElemen
|
|||
|
||||
let parseError = "";
|
||||
try {
|
||||
parseLabel(text);
|
||||
cachedParseLabel(text);
|
||||
} catch (e) {
|
||||
// @ts-ignore
|
||||
parseError = e.message;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue