Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. var App = React.createClass({
  2. render: function(){
  3. var Child;
  4. switch(this.props.route)
  5. {
  6. case 'about':
  7. Child = about;
  8. break;
  9. default:
  10. Child = Home;
  11. break;
  12. }
  13.  
  14. return (
  15. <div>
  16. <Child/>
  17. </div>
  18. );
  19. }
  20. });
  21.  
  22. function render(){
  23. var hashRoute = window.location.hash.substr(1);
  24. ReactDOM.render(<app route = {hashRoute} />, document.getElementById('app'));
  25. }
  26.  
  27. window.addEventListener('hashChange', render);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement