Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/react-server / src / serverSideRender / renderWithoutServerSide.tsx
Size: Mime:
import React from 'react'
import { renderToStaticMarkup } from 'react-dom/server'
import { Response } from './typings'
import { ServerHTML } from './HTML'

export function renderWithoutServerSide(res: Response, nonce: string) {
  if (process.env.DISABLE_SSR === 'true') {
    console.log('[SSR] ==> Handling react route without SSR')
  }

  // SSR is disabled so we will return an "empty" html page and
  // rely on the client to initialize and render the react application.
  const html = renderToStaticMarkup(
    <ServerHTML nonce={nonce} reactAppString="" styledTags={[]} />
  )
  res.status(200).send(`<!DOCTYPE html>${html}`)
  res.end()
}