Skip to content

Instantly share code, notes, and snippets.

@coryhouse
Created June 14, 2018 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save coryhouse/b0579b6a02fed80ba36a54e224884ce0 to your computer and use it in GitHub Desktop.
Save coryhouse/b0579b6a02fed80ba36a54e224884ce0 to your computer and use it in GitHub Desktop.
$ = 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