Guest User

Untitled

a guest
Jul 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. const app = new Koa()
  2.  
  3. app.use(async (ctx, next) => {
  4. await new Promise((resolve, reject) => {
  5. // `history` is memoryHistory, `store` is redux store, `routes` is usual react-router routes
  6. match({ history, routes, location: ctx.request.url }, (error, redirectLocation, renderProps) => {
  7. if (renderProps) {
  8. ctx.body = htmlTemplate(renderHTML(store, renderProps), store.getState()) // see below
  9. resolve()
  10. }
  11. })
  12. })
  13. await next()
  14. })
  15.  
  16. app.listen(3000)
Add Comment
Please, Sign In to add comment