Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <div data-reactroot="" data-reactid="1" data-react-checksum="-1424217736">
  2. <!-- react-empty: 2 --><!-- react-empty: 3 --><!-- react-empty: 4 --><!-- react-empty: 5 --></div>
  3.  
  4. app.use('*', (req, res) => {
  5.  
  6. const context = {}
  7. const store = configureStore()
  8.  
  9.  
  10. const markup = renderToString(
  11. <Provider store={store}>
  12. <StaticRouter
  13. location={req.url}
  14. context={context}
  15. >
  16. <Routes/>
  17. </StaticRouter>
  18. </Provider>
  19. )
  20.  
  21. console.log(markup)
  22.  
  23. if (context.url) {
  24. // Somewhere a `<Redirect>` was rendered
  25. redirect(301, context.url)
  26. } else {
  27. // we're good, send the response
  28. res.send(`
  29. <!doctype html>
  30. <head>
  31. <meta name="google-site-verification" content="P5pcBDBR0SrpH4kFMOp5Ush5JxDdG-3oPhjKO8Zf5WE" />
  32. </head>
  33. <body>
  34. <div id="app">${markup}</div>
  35. </body>
  36. `)
  37.  
  38.  
  39. }
  40. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement