Skip to content

Instantly share code, notes, and snippets.

@jschr
Last active April 12, 2017 04:20
Show Gist options
  • Save jschr/679dc9de6fa172c7f8b7a0ab1ed689d5 to your computer and use it in GitHub Desktop.
Save jschr/679dc9de6fa172c7f8b7a0ab1ed689d5 to your computer and use it in GitHub Desktop.
mount step 1
// index.ts imports both the mount and ssr functions
// because it's the entry point for the server and
// the browser
import mount from './mount'
import ssr from './ssr'
// dont mount if we are not running in the browser context
if (typeof document !== 'undefined') mount()
// the exported ssr function is only called by
// static-website-generator-webpack-plugin
export default ssr
import * as React from 'react'
import { render } from 'react-dom'
import App from './components/App'
// our mount function
export default function () {
// renders the app with the props provided by the
// server (set with the Template component)
const appProps = window.ssr.appProps
render(<App {...appProps} />, document.getElementById('react-root'))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment