2.hash history vs browser history


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import React from 'react';
  2. import { Router, Route, Link, browserHistory } 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="/02-hash-vs-browserHistory">Home</Link>
  10. <Link to="/02-hash-vs-browserHistory/about">About</Link>
  11. <Link to="/02-hash-vs-browserHistory/contact">Contact</Link>
  12. </nav>
  13.  
  14. const App = () => {
  15. return (
  16. <Router history={ browserHistory }>
  17. <Route path="02-hash-vs-browserHistory" component={Home}></Route>
  18. <Route path="02-hash-vs-browserHistory/about" component={About}></Route>
  19. <Route path="02-hash-vs-browserHistory/contact" component={Contact}></Route>
  20. </Router>
  21. )
  22. };
  23.  
  24. export default App;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.