Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const app = new Koa()
- app.use(async (ctx, next) => {
- await new Promise((resolve, reject) => {
- // `history` is memoryHistory, `store` is redux store, `routes` is usual react-router routes
- match({ history, routes, location: ctx.request.url }, (error, redirectLocation, renderProps) => {
- if (renderProps) {
- ctx.body = htmlTemplate(renderHTML(store, renderProps), store.getState()) // see below
- resolve()
- }
- })
- })
- await next()
- })
- app.listen(3000)
Add Comment
Please, Sign In to add comment