I would like the ability for the user to click a button using the React-VR cursor and be able to go to external and internal pages like this
onEnter={() => Linking.openURL("https://www.google.com").catch(err => console.error('An error occurred', err))}
or
onEnter={() => Linking.openURL("paris.vr.js").catch(err => console.error('An error occurred', err))}
But I'm getting the following error "Cannot read property 'openURL' of undefined"
How have you imported the Linking module?
Linking is a native module, so be sure to do the following:
import {
NativeModules,
// ... rest of your imports
} from 'react-vr';
const Linking = NativeModules.Linking;
Also, what do you mean by linking to "internal pages"? If you want to be able to deep-link into content, you may find it more useful to use the History module to change the url by pushing / popping values. This is how modern web applications allow deep-linking.
React VR 技术开发群 579149907
I found out this works:
import { NativeModules } from 'react-vr'
NativeModules.LinkingManager.openURL('<URL YOU WANT TO GO>')
Mix solution
import {
NativeModules,
// ... rest of your imports
} from 'react-vr';
const Linking = NativeModules.LinkingManager;
Linking.openURL('<URL YOU WANT TO GO>')
Most helpful comment
I found out this works: