6.router parameters


/ 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, hashHistory } from 'react-router';
  3.  
  4. const Message = (props) =>
  5. <div><h1>{props.params.message || 'Hello'}</h1><Links /></div>
  6.  
  7. const Links = () =>
  8. <nav>
  9. <Link to="/">Hello</Link>
  10. <Link to="/Hi">Hi</Link>
  11. <Link to="/Yo">Yo</Link>
  12. </nav>
  13.  
  14.  
  15. class App extends React.Component {
  16. render(){
  17. return (
  18. <Router history={ hashHistory }>
  19. <Route path="/(:message)" component={Message}></Route>
  20. </Router>
  21. );
  22. }
  23. }
  24.  
  25. export default App;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.