Created
June 14, 2018 19:24
-
-
Save coryhouse/b0579b6a02fed80ba36a54e224884ce0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ = jQuery = require('jquery'); | |
var React = require('react'); | |
var Home = require('./components/homePage'); | |
var About = require('./components/about/aboutPage'); | |
var App = React.createClass({ | |
render: function() { | |
var Child; | |
switch (this.props.route) { | |
case 'about': | |
Child = About; | |
break; | |
default: | |
Child = Home; | |
} | |
return ( | |
<div> | |
<Child /> | |
</div> | |
); | |
} | |
}); | |
function render() { | |
var route = window.location.hash.substr(1); | |
React.render(<app route={route} />, document.getElementById('app')); | |
} | |
window.addEventListener('hashchange', render); | |
render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment