From a4ff725b21647580a53b3de233fcb96c3fc183d8 Mon Sep 17 00:00:00 2001 From: Philipp Molitor Date: Sun, 7 Mar 2021 00:37:19 +0100 Subject: [PATCH 1/2] fix: unload previous context on context change --- src/components/UnityRenderer.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/UnityRenderer.ts b/src/components/UnityRenderer.ts index 86ef9dd..ddd97ff 100644 --- a/src/components/UnityRenderer.ts +++ b/src/components/UnityRenderer.ts @@ -135,8 +135,11 @@ export const UnityRenderer: VFC = ({ // on context change useEffect(() => { + // remove (previous) context if any + if (!context || context !== ctx) unmount(); + + // set new context if (context) setCtx(context); - else unmount(); }, [context]); // on mount From 7c0423ee516edfb8a0fc71993c3a43c86eeeafc6 Mon Sep 17 00:00:00 2001 From: Philipp Molitor Date: Sun, 7 Mar 2021 00:37:57 +0100 Subject: [PATCH 2/2] misc: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3544a40..e69bfef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-unity-renderer", - "version": "2020.0.2", + "version": "2020.0.3", "description": "React Unity Renderer allows to interactively embed Unity WebGL builds into a React powered project.", "main": "./dist/index.js", "types": "./dist/index.d.ts",