@samitouri / QOS-React / commits / 96d7e53e69

topLevelUpdateWarnings is only for dev mode hence not necessary to have extra dev mode check. (#11924)

Haisheng Wu committed Jan 5, 2018 at 10:51 UTC 96d7e53e693d5676cb379876c2b1370596899f86
1 file changed +34 -39
packages/react-dom/src/client/ReactDOM.js
+34 -39
@@ -97,50 +97,45 @@ if (__DEV__) {
97 }
98
99 topLevelUpdateWarnings = (container: DOMContainer) => {
100 - if (__DEV__) {
101 - if (
102 - container._reactRootContainer &&
103 - container.nodeType !== COMMENT_NODE
104 - ) {
105 - const hostInstance = DOMRenderer.findHostInstanceWithNoPortals(
106 - container._reactRootContainer._internalRoot.current,
100 + if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
101 + const hostInstance = DOMRenderer.findHostInstanceWithNoPortals(
102 + container._reactRootContainer._internalRoot.current,
103 + );
104 + if (hostInstance) {
105 + warning(
106 + hostInstance.parentNode === container,
107 + 'render(...): It looks like the React-rendered content of this ' +
108 + 'container was removed without using React. This is not ' +
109 + 'supported and will cause errors. Instead, call ' +
110 + 'ReactDOM.unmountComponentAtNode to empty a container.',
111 );
108 - if (hostInstance) {
109 - warning(
110 - hostInstance.parentNode === container,
111 - 'render(...): It looks like the React-rendered content of this ' +
112 - 'container was removed without using React. This is not ' +
113 - 'supported and will cause errors. Instead, call ' +
114 - 'ReactDOM.unmountComponentAtNode to empty a container.',
115 - );
116 - }
112 }
113 + }
114
119 - const isRootRenderedBySomeReact = !!container._reactRootContainer;
120 - const rootEl = getReactRootElementInContainer(container);
121 - const hasNonRootReactChild = !!(
122 - rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl)
123 - );
115 + const isRootRenderedBySomeReact = !!container._reactRootContainer;
116 + const rootEl = getReactRootElementInContainer(container);
117 + const hasNonRootReactChild = !!(
118 + rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl)
119 + );
120
125 - warning(
126 - !hasNonRootReactChild || isRootRenderedBySomeReact,
127 - 'render(...): Replacing React-rendered children with a new root ' +
128 - 'component. If you intended to update the children of this node, ' +
129 - 'you should instead have the existing children update their state ' +
130 - 'and render the new components instead of calling ReactDOM.render.',
131 - );
121 + warning(
122 + !hasNonRootReactChild || isRootRenderedBySomeReact,
123 + 'render(...): Replacing React-rendered children with a new root ' +
124 + 'component. If you intended to update the children of this node, ' +
125 + 'you should instead have the existing children update their state ' +
126 + 'and render the new components instead of calling ReactDOM.render.',
127 + );
128
133 - warning(
134 - container.nodeType !== ELEMENT_NODE ||
135 - !((container: any): Element).tagName ||
136 - ((container: any): Element).tagName.toUpperCase() !== 'BODY',
137 - 'render(): Rendering components directly into document.body is ' +
138 - 'discouraged, since its children are often manipulated by third-party ' +
139 - 'scripts and browser extensions. This may lead to subtle ' +
140 - 'reconciliation issues. Try rendering into a container element created ' +
141 - 'for your app.',
142 - );
143 - }
129 + warning(
130 + container.nodeType !== ELEMENT_NODE ||
131 + !((container: any): Element).tagName ||
132 + ((container: any): Element).tagName.toUpperCase() !== 'BODY',
133 + 'render(): Rendering components directly into document.body is ' +
134 + 'discouraged, since its children are often manipulated by third-party ' +
135 + 'scripts and browser extensions. This may lead to subtle ' +
136 + 'reconciliation issues. Try rendering into a container element created ' +
137 + 'for your app.',
138 + );
139 };
140
141 warnOnInvalidCallback = function(callback: mixed, callerName: string) {