From 82c044ee3379a655ea28bb61f6e239709345cad8 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Mon, 18 Dec 2017 16:15:47 +0000 Subject: [PATCH] [fix] use ReactDOM.hydrate in AppRegistry.runApplication Allows AppRegistry to hydrate server-side rendered apps. Fix #733 --- src/apis/AppRegistry/renderApplication.js | 4 ++-- src/modules/hydrate/index.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/modules/hydrate/index.js diff --git a/src/apis/AppRegistry/renderApplication.js b/src/apis/AppRegistry/renderApplication.js index 5503ebbe..71cf72c5 100644 --- a/src/apis/AppRegistry/renderApplication.js +++ b/src/apis/AppRegistry/renderApplication.js @@ -10,7 +10,7 @@ */ import invariant from 'fbjs/lib/invariant'; -import { render } from 'react-dom'; +import { hydrate } from '../../modules/hydrate'; import AppContainer from './AppContainer'; import StyleSheet from '../../apis/StyleSheet'; import React, { type ComponentType } from 'react'; @@ -22,7 +22,7 @@ export default function renderApplication( ) { invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag); - render( + hydrate( , diff --git a/src/modules/hydrate/index.js b/src/modules/hydrate/index.js new file mode 100644 index 00000000..5062302f --- /dev/null +++ b/src/modules/hydrate/index.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2016-present, Nicolas Gallagher. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + * + * @noflow + */ + +import { hydrate } from 'react-dom'; +export default hydrate;