From d4acc641ac0d9a7bc4be2653545f04433dcdb6e9 Mon Sep 17 00:00:00 2001 From: Hannah Mudge Date: Tue, 2 Jul 2024 12:55:16 -0600 Subject: [PATCH] Memoize `dataControlFactories` --- .../data_controls/data_control_editor.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/controls_example/public/react_controls/data_controls/data_control_editor.tsx b/examples/controls_example/public/react_controls/data_controls/data_control_editor.tsx index 007038db9addb..09923fad506ab 100644 --- a/examples/controls_example/public/react_controls/data_controls/data_control_editor.tsx +++ b/examples/controls_example/public/react_controls/data_controls/data_control_editor.tsx @@ -81,11 +81,13 @@ const CompatibleControlTypesComponent = ({ selectedControlType?: string; setSelectedControlType: (type: string) => void; }) => { - const dataControlFactories = getAllControlTypes() - .map((type) => getControlFactory(type)) - .filter((factory) => { - return isDataControlFactory(factory); - }); + const dataControlFactories = useMemo(() => { + return getAllControlTypes() + .map((type) => getControlFactory(type)) + .filter((factory) => { + return isDataControlFactory(factory); + }); + }, []); return (