Skip to content

Commit a22b0b2

Browse files
authored
Use script.remove instead of removeChild for unity loader hook (#576)
1 parent 2fdda26 commit a22b0b2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ const useUnityLoader = (unityConfig: UnityConfig): UnityLoaderStatus => {
1818
// this scenario, the window is not available. We can't create a Unity
1919
// Loader in this case.
2020
if (isBrowserEnvironment === false) {
21-
return;
21+
return undefined;
2222
}
2323
// If the script's source is null, we'll reset the status to idle.
2424
if (unityConfig.loaderUrl === null) {
2525
setStatus(UnityLoaderStatus.Idle);
26-
return;
26+
return undefined;
2727
}
2828
/**
2929
* Find existing script element by source. It may have been added by
@@ -78,7 +78,7 @@ const useUnityLoader = (unityConfig: UnityConfig): UnityLoaderStatus => {
7878
if (script !== null) {
7979
script.removeEventListener("load", setStateFromEvent);
8080
script.removeEventListener("error", setStateFromEvent);
81-
window.document.body.removeChild(script);
81+
script.remove();
8282
}
8383
};
8484
}, [unityConfig.loaderUrl]);

0 commit comments

Comments
 (0)