mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-31 01:36:11 +00:00
[fix] ReactDOM hydration warnings in development
Don't try to hydrate from SSR HTML during development. Fix #745
This commit is contained in:
@@ -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>,
|
||||||
|
|||||||
Reference in New Issue
Block a user