React-360: How to link to external and internal pages in React-VR?

Created on 8 May 2017  ·  4Comments  ·  Source: facebookarchive/react-360

Description

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"

Most helpful comment

I found out this works:

import { NativeModules } from 'react-vr'

NativeModules.LinkingManager.openURL('<URL YOU WANT TO GO>')

All 4 comments

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>')
Was this page helpful?
0 / 5 - 0 ratings