Skip to content

Commit a4ff725

Browse files
author
Philipp Molitor
committed
fix: unload previous context on context change
1 parent 557b604 commit a4ff725

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/UnityRenderer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ export const UnityRenderer: VFC<UnityRendererProps> = ({
135135

136136
// on context change
137137
useEffect(() => {
138+
// remove (previous) context if any
139+
if (!context || context !== ctx) unmount();
140+
141+
// set new context
138142
if (context) setCtx(context);
139-
else unmount();
140143
}, [context]);
141144

142145
// on mount

0 commit comments

Comments
 (0)