Last active
June 29, 2017 07:21
-
-
Save ygamretuta/d80dde19daed5ac648e704259bedcc70 to your computer and use it in GitHub Desktop.
Latest Most Up-to-Date Basic React Routing Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import { | |
BrowserRouter as Router, | |
Route | |
} from 'react-router-dom'; | |
class Home extends Component { | |
render() { | |
return (<h1>Home!</h1>); | |
} | |
} | |
class Car extends Component { | |
render() { | |
return (<h1>Cars Page</h1>); | |
} | |
} | |
class About extends Component { | |
render() { | |
return (<h1>About page</h1>); | |
} | |
} | |
// ======================================== | |
ReactDOM.render( | |
<Router> | |
<div> | |
<Route exact path="/" component={Home} /> | |
<Route path="/cars" component={Car} /> | |
<Route path="/about" component={About} /> | |
</div> | |
</Router>, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment