Skip to content

Commit

Permalink
fix(composer): Fix for useEffect error
Browse files Browse the repository at this point in the history
  • Loading branch information
mumanity committed Nov 16, 2022
1 parent ca01c40 commit 7e46795
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 7e46795

Please sign in to comment.