Skip to content

Instantly share code, notes, and snippets.

@isnifer
Last active August 29, 2015 14:24
Show Gist options
  • Save isnifer/e3209d71d3f31871ff3b to your computer and use it in GitHub Desktop.
Save isnifer/e3209d71d3f31871ff3b to your computer and use it in GitHub Desktop.
import 'babel/polyfill';
import 'isomorphic-fetch';
import React from 'react';
import Router from 'react-router';
import FluxComponent from 'flummox/component';
import Flux from '../flux';
import routes from './routes';
import '../less/main.less';
import performRouteHandlerStaticMethod from '../flux/performRouteHandlerStaticMethod';
var flux = new Flux();
var router = Router.create({
routes: routes,
location: Router.HistoryLocation
});
var mountNode = document.getElementById('main');
router.run(async (Handler, state) => {
const routeHandlerInfo = { state, flux };
performRouteHandlerStaticMethod(state.routes, 'routerWillRun', routeHandlerInfo).then(function (data) {
React.render(
<FluxComponent flux={flux}>
<Handler {...state} />
</FluxComponent>,
mountNode
);
});
});
import React from 'react';
import { Route, DefaultRoute, NotFoundRoute } from 'react-router';
import App from './handlers/App';
import MainPage from './handlers/MainPage';
import MyGames from './handlers/MyGames';
export default (
<Route name="app" path="/react" handler={App}>
<DefaultRoute name="main" handler={MainPage} />
<Route name="mygames" path="/react/mygames:type?:status?" handler={MyGames} />
</Route>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment