Skip to content

Instantly share code, notes, and snippets.

@pantharshit00
Last active April 13, 2017 08:41
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 pantharshit00/5ce7d967b843ee7f0c49bd0294600d51 to your computer and use it in GitHub Desktop.
Save pantharshit00/5ce7d967b843ee7f0c49bd0294600d51 to your computer and use it in GitHub Desktop.
React Router v4
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