From 7e46795ea35c639ce474575baa28a0c1cfa45b00 Mon Sep 17 00:00:00 2001 From: Emily Dodds Date: Wed, 16 Nov 2022 11:52:04 -0600 Subject: [PATCH] fix(composer): Fix for useEffect error --- .../SceneHierarchyPanel/SceneHierarchyDataProvider.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyDataProvider.tsx b/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyDataProvider.tsx index dc0334b96..ba30f5fb8 100644 --- a/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyDataProvider.tsx +++ b/packages/scene-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyDataProvider.tsx @@ -79,12 +79,18 @@ export const useChildNodes = (parentRef: string) => { const [childNodes, setChildNodes] = useState([] as ISceneHierarchyNode[]); useEffect(() => { + let mounted = true; (async () => { setLoading(true); const results = await getChildNodes(parentRef); - setChildNodes(results); - setLoading(false); + if (mounted) { + setChildNodes(results); + setLoading(false); + } })(); + return () => { + mounted = false; + }; }, [getChildNodes]); return [childNodes, loading] as [ISceneHierarchyNode[], boolean];