Skip to content

Commit 37fee33

Browse files
Minor improvements
1 parent de76d41 commit 37fee33

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

module/source/hooks/use-unity-context.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,14 @@ const useUnityContext = (unityConfig: IUnityConfig): IUnityContextHook => {
179179
// Re-attaches the canvas to the body element of the document. This way it
180180
// wont be removed from the DOM when the component is unmounted. Then the
181181
// canvas will be hidden while it is being unloaded.
182-
document.body.appendChild(unityInstance.Module.canvas as Node);
183-
unityInstance.Module.canvas.style.display = "none";
182+
const canvas = unityInstance.Module.canvas as HTMLCanvasElement;
183+
document.body.appendChild(canvas);
184+
canvas.style.display = "none";
184185
// Unloads the Unity Instance.
185186
await unload();
186187
// Eventually the canvas will be removed from the DOM. This has to be done
187188
// manually since the canvas is no longer controlled by the React DOM.
188-
unityInstance.Module.canvas.remove();
189+
canvas.remove();
189190
},
190191
[unityInstance]
191192
);

0 commit comments

Comments
 (0)