app/src/server.js
// We are going to fill these out in the sections to follow
We are going to fill these out in the sections to follow
We are going to fill these out in the sections to follow
function handleRender(req, res, next) {
  const memoryHistory = createMemoryHistory(req.originalUrl)
  let store = configureStore(memoryHistory )
  const history = syncHistoryWithStore(memoryHistory, store)
  match({ history, routes , location: req.originalUrl }, (error, redirectLocation, renderProps) => {
    if (error) {
      res.status(500).send(error.message)
    } else if (redirectLocation) {
      res.redirect(302, redirectLocation.pathname + redirectLocation.search)
    } else if (renderProps) {
      store = configureStore(memoryHistory, store.getState() )
      const content = renderToString(
        <Provider store={store}>
          <RouterContext {...renderProps}/>
        </Provider>
      )
      res.status(200).send(renderFullPage(content, store.getState()))
    }
  })
}
function handleRender ( req , res , next ) { const memoryHistory = createMemoryHistory ( req . originalUrl ) let store = configureStore ( memoryHistory ) const history = syncHistoryWithStore ( memoryHistory , store ) match ( { history , routes , location : req . originalUrl } , ( error , redirectLocation , renderProps ) => { if ( error ) { res . status ( 500 ) . send ( error . message ) } else if ( redirectLocation ) { res . redirect ( 302 , redirectLocation . pathname + redirectLocation . search ) } else if ( renderProps ) { store = configureStore ( memoryHistory , store . getState ( ) ) const content = renderToString ( < Provider store = { store } > < RouterContext { ... renderProps } / > < / Provider > ) res . status ( 200 ) . send ( renderFullPage ( content , store . getState ( ) ) ) } } ) }
We are going to fill these out in the sections to follow
We are going to fill these out in the sections to follow