Reputation: 33673
I have the following code:
import {
ViroBox,
ViroARScene,
ViroARSceneNavigator,
} from "@reactvision/react-viro";
import { StyleSheet, TouchableOpacity, TouchableWithoutFeedback } from "react-native";
const HelloWorldSceneAR = () => {
return (
<ViroARScene>
<ViroBox onClick={()=>{console.log("Clicked")}} />
</ViroARScene>
);
};
export default () => {
return (
<ViroARSceneNavigator
autofocus={true}
initialScene={{
scene: HelloWorldSceneAR,
}}
style={styles.f1}
/>
);
};
var styles = StyleSheet.create({
f1: { flex: 1 }
});
This code runs fine on Android devices. But on iOS devices, I get the error:
Exception thrown while executing UI block: -[VRTBox setOnClick:]: unrecognized selector sent to instance 0x111595d00
If I delete the onClick
, then the error message on iOS devices disappear. However, this means I lose the ability to tap on the ViroBox on iOS devices.
I also tried this:
<ViroARScene>
<TouchableOpacity onPress={()=>{console.log("Clicked")}}>
<ViroBox />
</TouchableOpacity>
</ViroARScene>
But this gave the error
Exception thrown while executing UI block: -[RCTView setSuperview:]: unrecognized selector sent to instance 0x1115868e0
I also tried this:
<ViroARScene>
<TouchableWithoutFeedback onPress={()=>{console.log("Clicked")}}>
<ViroBox />
</TouchableWithoutFeedback>
</ViroARScene>
But that gave this error:
Exception thrown while executing UI block: -[VRTBox setOnClick:]: unrecognized selector sent to instance 0x111595d10
What am I doing wrong?
And this is my package.json
{
"name": "ViroStarterKit",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@reactvision/react-viro": "^2.41.4",
"react": "18.2.0",
"react-native": "0.73.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "0.73.20",
"@react-native/eslint-config": "0.73.2",
"@react-native/metro-config": "0.73.4",
"@react-native/typescript-config": "0.73.1",
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"eslint": "^8.19.0",
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.2.0",
"typescript": "5.0.4"
},
"engines": {
"node": ">=18"
}
}
Other notes...I've tried using @reactvision/react-viro
version 2.41.3, 2.41.4, 2.41.5 and 2.41.6
, but they all encounter this problem.
Upvotes: 0
Views: 57