How to use the react-router.HistoryLocation function in react-router

To help you get started, we’ve selected a few react-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pheuter / essential-react / src / main.jsx View on Github external
*/
let fetchData = function(routes, params) {
  let data = {};

  return Promise.all(routes
    .filter(route => route.handler.fetchData)
    .map(route => {
      return route.handler.fetchData(params).then(resp => {
        data[route.name] = resp;
      })
    })
  ).then(() => data);
}

// Start the router
Router.run(routes, Router.HistoryLocation, function(Handler, state) {
  fetchData(state.routes, state.params).then((data) => {
    React.render(, document.getElementById(DOM_APP_EL_ID));
  });
});
github thorgate / django-project-template / {{cookiecutter.repo_name}} / {{cookiecutter.repo_name}} / app-spa / src / client.js View on Github external
Iso.on('iso', 1, function(state, meta, container) {
    alt.bootstrap(state);

    // Set correct language
    const activeLanguage = require('./stores/CurrentUserStore').default.getState().activeLanguage;
    logger.debug(`Set language to: ${activeLanguage}`);
    i18n.forceLanguage(activeLanguage);

    Router.run(routes, Router.HistoryLocation, (Handler, props) => {
        props.buffer = new Render.DispatchBuffer();
        React.render(, container);
    });
});
github irvinebroque / isomorphic-hot-loader / client.js View on Github external
var Router = require('react-router');
var RouteHandler = Router.RouteHandler;

// Set a device type based on window width, so that we can write media queries in javascript
// by calling if (this.props.deviceType === "mobile")
var deviceType;

if (window.matchMedia("(max-width: 639px)").matches) {
  deviceType = "mobile";
} else if (window.matchMedia("(max-width: 768px)").matches) {
  deviceType = "tablet";
} else {
  deviceType = "desktop";
}

Router.run(routes, Router.HistoryLocation, function (Handler, state) {
  React.render(, document.body);
});
github cobbweb / isomorphic-react-example / src / app / index.jsx View on Github external
// Browser entry point
require('react-tap-event-plugin')();

var React    = require('react/addons');
var Router   = require('react-router');
var resolver = require('react-resolver').create();
var routes   = resolver.route(require('./routes'));

var appContainer = document.getElementById('app');

React.render(<div>Loading</div>, appContainer);

Router.run(routes, Router.HistoryLocation, (Handler) =&gt; {
  resolver.resolve().then(function() {
    React.render(, appContainer);
  });
});
github jxnblk / static-react / app.js View on Github external
module.exports = function(options) {

  try {
    return Router.run(routes(options), Router.HistoryLocation, function(Handler, state) {
        React.render(React.createElement(Handler, window.INITIAL_PROPS), document);
    });
  } catch(e) {
    console.error('Router error');
    console.error(e);
  }

};
github reapp / reapp / src / run.js View on Github external
function renderSync() {
    Router.run(routes, Router.HistoryLocation, (Handler, state) => {
      fetchAllData(state.routes, state.params).then(data => render(Handler, data));
    });
  }
github eiriklv / fluxity-starter-auth / flux / client.jsx View on Github external
document.addEventListener('DOMContentLoaded', function(event) {
  let initialContext = window.__initialContext || {};

  let flux = Flux({
    Stores: stores,
    Actions: actions
  });

  flux.rehydrate(initialContext);
  flux.enableUpdates(false);
  
  let router = Router.create({
    routes: routes,
    location: Router.HistoryLocation,
    transitionContext: flux.getContext()
  });

  flux.addToContext('Router', router);
  flux.addToContext('Services', services);

  router.run(function(Handler, routerState) {
    flux.enableUpdates(true);

    React.render(
      ,
      document.querySelector('#app')
    );
github jarsbe / book-shelf / src / app.jsx View on Github external
document.addEventListener('DOMContentLoaded', () =&gt;
  Router.run(routes, Router.HistoryLocation, (Handler) =&gt;
    React.render(, document.getElementById('app'))
  )
);
github mrblueblue / isomorphic-react / src / client.js View on Github external
Iso.bootstrap((state, _, container) => {
  alt.bootstrap(state);

  Router.run(reactRoutes, Router.HistoryLocation, (Handler) => {
    const node = React.createElement(Handler);
    React.render(node, container);
  });
});
github micahlmartin / nuts / app / assets / javascript / views / shared / main.jsx View on Github external
module.exports.renderClient = function(callback) {
  Router.run(routes, Router.HistoryLocation, callback);
}