From 75159f15739bee746e6da6cf92005e5d713adf30 Mon Sep 17 00:00:00 2001 From: Brent Jackson Date: Thu, 7 Dec 2017 15:23:07 -0500 Subject: [PATCH] Render to documentElement --- docs/App.js | 204 ++++++++++++++++++++++---------------------- docs/index.html | 29 +------ lib/dev/entry.js | 3 +- lib/static/entry.js | 2 +- lib/static/index.js | 3 - package.json | 4 +- 6 files changed, 110 insertions(+), 135 deletions(-) diff --git a/docs/App.js b/docs/App.js index c691136..f5cfd42 100644 --- a/docs/App.js +++ b/docs/App.js @@ -19,107 +19,111 @@ import BtnOutline from './BtnOutline' import Tweet from './Tweet' const App = connect(props => - {props.title} - - - - - - -

x0 32

Zero-config React development environment and static site generator
v3.0.0-2
npm install @compositor/x0
Features
Isolated development environment
Static site generator
Hot reloading
Works with virtually any React component
No convoluted APIs to learn
No boilerplate required
Routing with react-router
Works with CSS-in-JS libraries like styled-components
Support for async data fetching
Get Started
Read the docs and get started on GitHub or sign up for updates.
DocumentationSign Up
© 2017 Compositor, Inc.
- +Hello

Beep 0

+ diff --git a/lib/dev/entry.js b/lib/dev/entry.js index 4a64cae..2e5c46a 100644 --- a/lib/dev/entry.js +++ b/lib/dev/entry.js @@ -2,7 +2,7 @@ const React = require('react') const { render } = require('react-dom') const App = require('./App') -const div = document.body +const div = typeof APP !== 'undefined' ? APP : document.documentElement const id = require.resolve(COMPONENT) const req = require(COMPONENT) @@ -19,7 +19,6 @@ if (module.hot) { module.hot.accept(id, function () { const next = require(COMPONENT) const NextComponent = next.default || next - console.log('app', app) app.setState({ Component: NextComponent }) diff --git a/lib/static/entry.js b/lib/static/entry.js index e8bae9c..66c88ec 100644 --- a/lib/static/entry.js +++ b/lib/static/entry.js @@ -6,7 +6,7 @@ const App = require(COMPONENT).default || require(COMPONENT) const data = document.getElementById('__initial-props__').innerHTML const props = JSON.parse(data) -const div = document.body +const div = typeof APP !== 'undefined' ? APP : document.documentElement hydrate( React.createElement(App, props), diff --git a/lib/static/index.js b/lib/static/index.js index 4d5446c..3525abe 100644 --- a/lib/static/index.js +++ b/lib/static/index.js @@ -21,14 +21,11 @@ const createHTML = ({ scripts = [] }) => (` -${getHead(initialProps)} ${body} ${initialProps ? `` : ''} ${scripts.map(src => ``)} `) -const getHead = props => typeof props.head === 'string' ? props.head : '' - const render = (Component, props, isStatic) => (isStatic ? renderToStaticMarkup : renderToString)( React.createElement(Component, props) diff --git a/package.json b/package.json index 1b1ccd9..baa510d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@compositor/x0", - "version": "3.0.0-3", + "version": "3.0.0-4", "description": "Zero-config React development environment and static site generator", "main": "index.js", "bin": { @@ -9,7 +9,7 @@ "scripts": { "start": "./bin/cli.js dev docs/App.js -op 8888", "build": "./bin/cli.js build docs/App.js --static -d docs", - "client": "./bin/cli.js build docs/App.js -d docs", + "client": "./bin/cli.js build docs/Root.js -d docs", "test": "nyc ava", "cover": "nyc report --reporter=html --reporter=lcov" },