Skip to content

Commit

Permalink
[fix] ReactDOM hydration warnings in development
Browse files Browse the repository at this point in the history
Don't try to hydrate from SSR HTML during development.

Fix #745
  • Loading branch information
necolas committed Dec 30, 2017
1 parent 86263a2 commit 41d90e0
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@
* @flow
*/

import AppContainer from './AppContainer';
import invariant from 'fbjs/lib/invariant';
import hydrate from '../../modules/hydrate';
import AppContainer from './AppContainer';
import render from '../../modules/render';
import StyleSheet from '../../apis/StyleSheet';
import React, { type ComponentType } from 'react';

const renderFn = process.env.NODE_ENV !== 'production' ? render : hydrate;

export default function renderApplication<Props: Object>(
RootComponent: ComponentType<Props>,
initialProps: Props,
rootTag: any
) {
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);

hydrate(
renderFn(
<AppContainer rootTag={rootTag}>
<RootComponent {...initialProps} />
</AppContainer>,
Expand Down

0 comments on commit 41d90e0

Please sign in to comment.