Posted By

dylansong on 06/08/16


Tagged


Versions (?)

1.Link


 / Published in: Other
 

  1. import React from 'react';
  2. import { Router, Route, Link, hashHistory } from 'react-router';
  3.  
  4. const Home = () => <div><h1>Home</h1><Links /></div>;
  5. const About = () => <div><h1>About</h1><Links /></div>;
  6. const Contact = () => <div><h1>Contact</h1><Links /></div>;
  7. const Links = () =>
  8. <nav>
  9. <Link to="/">Home</Link>
  10. <Link to="about">About</Link>
  11. <Link to="contact">Contact</Link>
  12. </nav>
  13.  
  14.  
  15. const App = () => {
  16. return (
  17. <Router history={ hashHistory }>
  18. <Route path="/" component={Home}></Route>
  19. <Route path="/about" component={About}></Route>
  20. <Route path="/contact" component={Contact}></Route>
  21. </Router>
  22. )
  23. };
  24.  
  25. export default App;

Report this snippet  

You need to login to post a comment.