Skip to content

Commit 784ee9d

Browse files
update: Fix ViroARSceneNavigator (#380)
This change addresses a bug where the this context was lost due to _project method not being an arrow function.
1 parent fe32486 commit 784ee9d

File tree

3 files changed

+34
-35
lines changed

3 files changed

+34
-35
lines changed

components/AR/ViroARSceneNavigator.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
ViroSceneDictionary,
2929
} from "../Types/ViroUtils";
3030

31-
3231
const ViroARSceneNavigatorModule = NativeModules.VRTARSceneNavigatorModule;
3332

3433
let mathRandomOffset = 0;
@@ -152,12 +151,25 @@ export class ViroARSceneNavigator extends React.Component<Props, State> {
152151
* @param point
153152
* @returns
154153
*/
155-
async _project(point: Viro3DPoint) {
154+
_project = async (point: Viro3DPoint) => {
156155
return await ViroARSceneNavigatorModule.project(
157156
findNodeHandle(this),
158157
point
159158
);
160-
}
159+
};
160+
161+
/**
162+
* TODO: Document _unproject
163+
*
164+
* @param point
165+
* @returns
166+
*/
167+
_unproject = async (point: Viro3DPoint) => {
168+
return await ViroARSceneNavigatorModule.unproject(
169+
findNodeHandle(this),
170+
point
171+
);
172+
};
161173

162174
/**
163175
* Gets a random tag string.
@@ -506,19 +518,6 @@ export class ViroARSceneNavigator extends React.Component<Props, State> {
506518
return -1;
507519
};
508520

509-
/**
510-
* TODO: Document _unproject
511-
*
512-
* @param point
513-
* @returns
514-
*/
515-
_unproject = async (point: Viro3DPoint) => {
516-
return await ViroARSceneNavigatorModule.unproject(
517-
findNodeHandle(this),
518-
point
519-
);
520-
};
521-
522521
/**
523522
* [iOS Only]
524523
*

dist/components/AR/ViroARSceneNavigator.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,14 @@ export declare class ViroARSceneNavigator extends React.Component<Props, State>
8383
* @param point
8484
* @returns
8585
*/
86-
_project(point: Viro3DPoint): Promise<any>;
86+
_project: (point: Viro3DPoint) => Promise<any>;
87+
/**
88+
* TODO: Document _unproject
89+
*
90+
* @param point
91+
* @returns
92+
*/
93+
_unproject: (point: Viro3DPoint) => Promise<any>;
8794
/**
8895
* Gets a random tag string.
8996
*
@@ -190,13 +197,6 @@ export declare class ViroARSceneNavigator extends React.Component<Props, State>
190197
* @returns the index of the scene
191198
*/
192199
getSceneIndex: (sceneTag: string) => number;
193-
/**
194-
* TODO: Document _unproject
195-
*
196-
* @param point
197-
* @returns
198-
*/
199-
_unproject: (point: Viro3DPoint) => Promise<any>;
200200
/**
201201
* [iOS Only]
202202
*

dist/components/AR/ViroARSceneNavigator.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,18 @@ class ViroARSceneNavigator extends React.Component {
110110
* @param point
111111
* @returns
112112
*/
113-
async _project(point) {
113+
_project = async (point) => {
114114
return await ViroARSceneNavigatorModule.project((0, react_native_1.findNodeHandle)(this), point);
115-
}
115+
};
116+
/**
117+
* TODO: Document _unproject
118+
*
119+
* @param point
120+
* @returns
121+
*/
122+
_unproject = async (point) => {
123+
return await ViroARSceneNavigatorModule.unproject((0, react_native_1.findNodeHandle)(this), point);
124+
};
116125
/**
117126
* Gets a random tag string.
118127
*
@@ -403,15 +412,6 @@ class ViroARSceneNavigator extends React.Component {
403412
// Unable to find the given sceneTag, return -1
404413
return -1;
405414
};
406-
/**
407-
* TODO: Document _unproject
408-
*
409-
* @param point
410-
* @returns
411-
*/
412-
_unproject = async (point) => {
413-
return await ViroARSceneNavigatorModule.unproject((0, react_native_1.findNodeHandle)(this), point);
414-
};
415415
/**
416416
* [iOS Only]
417417
*

0 commit comments

Comments
 (0)