Skip to content

Instantly share code, notes, and snippets.

View slyder's full-sized avatar

Konstantin slyder

  • Sevastopol, Ukraine
View GitHub Profile
app.use(async function (req, res, next) {
try {
const memoryHistory = createMemoryHistory(req.url);
const store = configureStore(memoryHistory);
const history = syncHistoryWithStore(memoryHistory, store);
const html = await new Promise((resolve, reject) => {
// match the routes to the url
match({history, routes, location: req.url }, (err, redirect, renderProps) => {
// express method
app.use(async function (req, res, next) {
try {
let flux = new Flux();
var {HandlerComponent, state} = await AuxService.runReactRouter(reactRoutes, req.url);
await AuxService.performRouteHandlerStaticMethod(state.routes, 'routerWillRun', {state, flux, req});
...
}