From 13e24680327af23771afdf0ee11f57b0ee33ba1e Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 31 Jan 2021 03:14:34 -0600 Subject: [PATCH] chore: leaks --- .../src/resource-controllers/entity/index.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/entity/src/resource-controllers/entity/index.jsx b/packages/entity/src/resource-controllers/entity/index.jsx index aef43ca..5b08b6b 100644 --- a/packages/entity/src/resource-controllers/entity/index.jsx +++ b/packages/entity/src/resource-controllers/entity/index.jsx @@ -32,18 +32,24 @@ const EntityComponent = ({ const {Entity} = latus.get('%resources'); const [entity, setEntity] = useState(); useEffect(() => { - if (entity) { - entity.destroy(); - } setEntity(); const loadEntity = async () => { setEntity(await Entity.load(resource)); }; loadEntity(); + return () => { + if (entity) { + entity.destroy(); + } + setEntity(); + }; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [Entity, uri]); + }, [Entity, join(uri, path)]); useEffect(() => { - entity?.load(resource); + const load = async () => { + await entity?.load(resource); + }; + load(); }, [Entity, entity, resource]); if (!entity) { return null;