Skip to content

Instantly share code, notes, and snippets.

@ooade
Created July 21, 2016 21:29
Show Gist options
  • Save ooade/9c38527e6c5e70dd73c8938c2e78bd63 to your computer and use it in GitHub Desktop.
Save ooade/9c38527e6c5e70dd73c8938c2e78bd63 to your computer and use it in GitHub Desktop.
Main JS file with react-router
// Grab the react and react-dom pkgs -->
import React from 'react';
import ReactDOM from 'react-dom';
// Grab Router, Route and browserHistory from react-router ->
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
// Grab Navigation component -->
import Navigation from '../components/navigation';
// Write an App Component -->
const App = () => {
return (
<div>
<Navigation />
</div>
);
};
// Start Routes -->
const routes = (
<Router history={browserHistory}>
<Route path="/" component={App}>
{/*...We will have some other routes here...*/}
</Route>
</Router>
);
// Render the App Component to the app class
// Use Meteor.startup (Makes sure the Meteor app starts up before you try rendering to the DOM)
Meteor.startup(() => {
ReactDOM.render(routes, document.querySelector('.app'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment