ReactVision / viro

ViroReact: The AR and VR library for React Native πŸ“³πŸ’™πŸ’›πŸ€πŸ’š
MIT License
1.3k stars 150 forks source link

Patch for Viro3DSceneNavigator & ViroScene #186

Closed g-pex-aerian closed 5 months ago

g-pex-aerian commented 1 year ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch @viro-community/react-viro@2.23.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@viro-community/react-viro/components/Viro3DSceneNavigator.tsx b/node_modules/@viro-community/react-viro/components/Viro3DSceneNavigator.tsx
index 68d8eed..4d7899e 100644
--- a/node_modules/@viro-community/react-viro/components/Viro3DSceneNavigator.tsx
+++ b/node_modules/@viro-community/react-viro/components/Viro3DSceneNavigator.tsx
@@ -484,7 +484,11 @@ export class Viro3DSceneNavigator extends React.Component<Props, State> {
     // If the user simply passes us the props from the root React component,
     // then we'll have an extra 'rootTag' key which React automatically includes
     // so remove it.
-    delete this.sceneNavigator.viroAppProps.rootTag;
+    try {
+        delete this.sceneNavigator.viroAppProps.rootTag;
+      } catch (error) {
+        console.log(error)
+    }

     const {
       viroAppProps = {}, // Make sure viroAppProps aren't null to save us having to always check
diff --git a/node_modules/@viro-community/react-viro/components/ViroScene.tsx b/node_modules/@viro-community/react-viro/components/ViroScene.tsx
index d860cfd..547d48f 100644
--- a/node_modules/@viro-community/react-viro/components/ViroScene.tsx
+++ b/node_modules/@viro-community/react-viro/components/ViroScene.tsx
@@ -55,7 +55,7 @@ export class ViroScene extends ViroBase<Props> {
      */
     event.nativeEvent.platformInfoViro.vrPlatform =
       event.nativeEvent.platformInfoViro.platform;
-    this.props.onPlatformUpdate &&
+    this.props?.onPlatformUpdate &&
       this.props.onPlatformUpdate(event.nativeEvent.platformInfoViro);
   }

This issue body was partially generated by patch-package.

g-pex-aerian commented 1 year ago

Fixes: https://github.com/ViroCommunity/viro/issues/134

robertjcolley commented 5 months ago

Fixed this in another patch. Closing! πŸ˜„