Skip to content

Commit

Permalink
Merge pull request #27 from gky360/fix/cleanup-old-component
Browse files Browse the repository at this point in the history
Add cleanup function to remove old component
  • Loading branch information
gky360 authored Nov 10, 2021
2 parents a776398 + 4cc4498 commit 57f984f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/Component/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ export const Component: React.FC<ComponentProps> = ({
}
}, [component, onLoad]);

useEffect(() => {
return () => {
if (component) {
stage.removeComponent(component);
}
};
}, [component, stage]);

useEffect(() => {
if (component) {
const nextParams = mergeParams(params, ComponentDefaultParameters);
Expand Down

0 comments on commit 57f984f

Please sign in to comment.