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} = latus.get('%resources');
const [entity, setEntity] = useState(); const [entity, setEntity] = useState();
useEffect(() => { useEffect(() => {
if (entity) {
entity.destroy();
}
setEntity(); setEntity();
const loadEntity = async () => { const loadEntity = async () => {
setEntity(await Entity.load(resource)); setEntity(await Entity.load(resource));
}; };
loadEntity(); loadEntity();
return () => {
if (entity) {
entity.destroy();
}
setEntity();
};
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [Entity, uri]); }, [Entity, join(uri, path)]);
useEffect(() => { useEffect(() => {
entity?.load(resource); const load = async () => {
await entity?.load(resource);
};
load();
}, [Entity, entity, resource]); }, [Entity, entity, resource]);
if (!entity) { if (!entity) {
return null; return null;