chore: cleanup

This commit is contained in:
cha0s 2021-01-26 11:31:14 -06:00
parent f200518edd
commit a0e45b463f
2 changed files with 5 additions and 0 deletions

View File

@ -29,6 +29,7 @@ const Stage = ({
return () => { return () => {
if (renderer) { if (renderer) {
container.removeChild(renderer.element); container.removeChild(renderer.element);
renderer.destroy();
} }
if (handle) { if (handle) {
clearInterval(handle); clearInterval(handle);

View File

@ -9,11 +9,15 @@ export default (json) => {
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(json)); setEntity(await Entity.load(json));
}; };
loadEntity(); loadEntity();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [Entity, json]); }, [Entity, json]);
return entity; return entity;
}; };