Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
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));
});
});
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);
});
});
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);
});
// 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) => {
resolver.resolve().then(function() {
React.render(, appContainer);
});
});
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);
}
};
function renderSync() {
Router.run(routes, Router.HistoryLocation, (Handler, state) => {
fetchAllData(state.routes, state.params).then(data => render(Handler, data));
});
}
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')
);
document.addEventListener('DOMContentLoaded', () =>
Router.run(routes, Router.HistoryLocation, (Handler) =>
React.render(, document.getElementById('app'))
)
);
Iso.bootstrap((state, _, container) => {
alt.bootstrap(state);
Router.run(reactRoutes, Router.HistoryLocation, (Handler) => {
const node = React.createElement(Handler);
React.render(node, container);
});
});
module.exports.renderClient = function(callback) {
Router.run(routes, Router.HistoryLocation, callback);
}