nextjs use react-unity-webgl Failed to execute ‘removeChild’ on ‘Node’ error

// CloseCode

async function closeModal() {
  await detachAndUnloadImmediate();
  await queryClient.setQueryData("isModal", false);
}



useEffect(() => {
  return () => {
    detachAndUnloadImmediate();
  };
}, [detachAndUnloadImmediate]);




// Unity
<ContentAvatarViewer>
  {isLoaded === false && <div>loading</div>}
   <Unity
     unityProvider={unityProvider}
     style={{ width: 700, height: 700 }}
   />
</ContentAvatarViewer>

enter image description here

Currently, I am implementing it in modal form, and when I exit the modal, I unmount unity and then terminate it.

However, the above error occurs when moving to the next page after the modal is closed.

I don’t know what the hell the problem is.

Currently, I am implementing it in modal form, and when I exit the modal, I unmount unity and then terminate it.

However, the above error occurs when moving to the next page after the modal is closed.

I don’t know what the hell the problem is.