chore: leaks

This commit is contained in:
cha0s 2021-01-31 03:14:34 -06:00
parent 3af9037da4
commit 13e2468032

View File

@ -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;