How to use react React Router with React VR?

Viewed 879

I'm trying to figure out how to plug React Router with React VR.

First, should I use react-router dom / native? it's not clear since React VR builds on top of React Native, but runs in the browser.

This is the code I'm having issues with.

import React from 'react';

import { AppRegistry } from 'react-vr';

import {
  BrowserRouter as Router,
  Route
} from 'react-router-dom'

import Landing from './components/Landing';
import Video from './components/Video';

export default class WelcomeToVR extends React.Component {
  render() {
    return (
      <Router>
        <Route exact path={'/vr/'} component={Landing} />
        <Route exact path={'/vr/video/'} component={Video} />
      </Router>
    );
  }
};

AppRegistry.registerComponent('WelcomeToVR', () => WelcomeToVR);

The above code returns the following errors when opening the browser on /vr/: React Router + React VR errors

3 Answers

React-VR does not use the normal history APIs of other applications. Memory Router is the option listed above, but I recommend conditional rendering.

You can use the History API from Native Modules instead to load information into the URL.

Related