Last active
April 13, 2017 08:41
-
-
Save pantharshit00/5ce7d967b843ee7f0c49bd0294600d51 to your computer and use it in GitHub Desktop.
React Router v4
This file contains hidden or 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 from 'react'; | |
import ReactDOM from 'react-dom'; | |
import {BrowserRouter as Router,Link,Route} from 'react-router-dom'; | |
export default class App extends React.Component{ | |
render(){ | |
return( | |
<Router> | |
<div> | |
<ul> | |
<li><Link to="/">Home</Link></li> | |
<li><Link to="/about">About</Link></li> | |
</ul> | |
<hr/> | |
<Route exact path="/" component={Home} /> | |
<Route path="/about" component={About} /> | |
</div> | |
</Router> | |
) | |
} | |
} | |
//State less components | |
//Home | |
const Home = ()=> ( | |
<div> | |
<h1>Home</h1> | |
<p>This is the Home Page</p> | |
</div> | |
) | |
//About | |
const About = ()=>( | |
<div> | |
<h1>About</h1> | |
<p>This is about</p> | |
</div> | |
) | |
ReactDOM.render(<App />,document.getElementById('app')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment