Skip to content

Instantly share code, notes, and snippets.

@lopezjurip
Last active October 19, 2017 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lopezjurip/0703eb5feaa6a96b0ee60c36578f18d8 to your computer and use it in GitHub Desktop.
Save lopezjurip/0703eb5feaa6a96b0ee60c36578f18d8 to your computer and use it in GitHub Desktop.
Using create-react-app with React Router + Express.js
// src/routes.js
import React from 'react';
import { Router, Route } from 'react-router';
import App from './components/App';
import About from './components/About';
import NotFound from './components/NotFound';
const Routes = (props) => (
<Router {...props}>
<Route path="/" component={App} />
<Route path="/about" component={About} />
<Route path="*" component={NotFound} />
</Router>
);
export default Routes;
@tiagobbraga
Copy link

With react-router-dom

import React from 'react';
import { Route, Switch } from 'react-router-dom'
import App from './components/App';
import About from './components/About';
import NotFound from './components/NotFound';
const Routes = (props) => (
  <Switch>
    <Route exact path="/" component={App} />
    <Route path="/about" component={About} />
    <Route component={NotFound} />
  </Switch>
);
export default Routes;

Guide for migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment