From 0d14216e9feb89a448a2f4f788a221a4103a026f Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Mon, 2 May 2022 21:05:59 +0000 Subject: [PATCH] Refactor and rename lambda in partial --- packages/components/src/components/SquiggleEditor.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/components/src/components/SquiggleEditor.tsx b/packages/components/src/components/SquiggleEditor.tsx index 8ea70afa..9a453ab8 100644 --- a/packages/components/src/components/SquiggleEditor.tsx +++ b/packages/components/src/components/SquiggleEditor.tsx @@ -166,7 +166,7 @@ export let SquigglePartial: React.FC = ({ let [expression, setExpression] = React.useState(initialSquiggleString); let [error, setError] = React.useState(null); - React.useEffect(() => { + let runSquiggleAndUpdateBindings = () => { let squiggleResult = runPartial( expression, bindings, @@ -179,7 +179,9 @@ export let SquigglePartial: React.FC = ({ } else { setError(errorValueToString(squiggleResult.value)); } - }, [expression]); + }; + + React.useEffect(runSquiggleAndUpdateBindings, [expression]); return (