Last active
April 12, 2017 04:20
-
-
Save jschr/679dc9de6fa172c7f8b7a0ab1ed689d5 to your computer and use it in GitHub Desktop.
mount step 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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