Update react-router and react-router-relay to v2.x from v1.x (Location “/” did not match any routes)

泄露秘密 提交于 2019-12-04 11:53:53

Finally got an answer to this question and had to add the following changes to make my code work again:

import babelPolyfill from 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import Loader from 'react-loader';

import Relay from 'react-relay';
import useRelay from 'react-router-relay';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
import applyRouterMiddleware from 'react-router/lib/applyRouterMiddleware';

import WelcomeQueries from './queries/WelcomeQueries';
import AppQueries from './queries/AppQueries';
import LandingQueries from './queries/LandingQueries';

import App from './components/app';
import Landing from './components/landing';

import './relay';

ReactDOM.render((
  <Router 
    history={browserHistory} 
    render={applyRouterMiddleware(useRelay)} 
    environment={Relay.Store}>

    <Route 
      component={App} 
      queries={AppQueries} 
      render={({ props }) => props ? <App {...props} /> : <Loader />}>

      <Route 
        path="/myapp" 
        component={Landing} 
        queries={LandingQueries} 
        render={({ props }) => props ? <Landing {...props} /> : <Loader />} />
    </Route>

    <Route 
      path="/myapp/tracks" 
      component={Welcome} 
      queries={WelcomeQueries} 
      render={({ props }) => props ? <Welcome {...props} /> : <Loader />} />

  </Router>
), document.getElementById('myapp-body'));

Maybe this will help someone else :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!