[fix] ReactDOM hydration warnings in development

Don't try to hydrate from SSR HTML during development.

Fix #745
This commit is contained in:
Nicolas Gallagher
2017-12-30 14:01:58 -08:00
parent 86263a2fa0
commit 41d90e0238
@@ -9,12 +9,15 @@
* @flow * @flow
*/ */
import AppContainer from './AppContainer';
import invariant from 'fbjs/lib/invariant'; import invariant from 'fbjs/lib/invariant';
import hydrate from '../../modules/hydrate'; import hydrate from '../../modules/hydrate';
import AppContainer from './AppContainer'; import render from '../../modules/render';
import StyleSheet from '../../apis/StyleSheet'; import StyleSheet from '../../apis/StyleSheet';
import React, { type ComponentType } from 'react'; import React, { type ComponentType } from 'react';
const renderFn = process.env.NODE_ENV !== 'production' ? render : hydrate;
export default function renderApplication<Props: Object>( export default function renderApplication<Props: Object>(
RootComponent: ComponentType<Props>, RootComponent: ComponentType<Props>,
initialProps: Props, initialProps: Props,
@@ -22,7 +25,7 @@ export default function renderApplication<Props: Object>(
) { ) {
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag); invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);
hydrate( renderFn(
<AppContainer rootTag={rootTag}> <AppContainer rootTag={rootTag}>
<RootComponent {...initialProps} /> <RootComponent {...initialProps} />
</AppContainer>, </AppContainer>,