Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Suppress warning of inserted/deleted direct children
  • Loading branch information
sebmarkbage committed Oct 6, 2017
commit ce62a4f40835a81c3c7d3eda41f11e3e22fb8511
38 changes: 26 additions & 12 deletions src/renderers/dom/fiber/ReactDOMFiberEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var {
var {precacheFiberNode, updateFiberProps} = ReactDOMComponentTree;

if (__DEV__) {
var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
var lowPriorityWarning = require('lowPriorityWarning');
var warning = require('fbjs/lib/warning');
var validateDOMNesting = require('validateDOMNesting');
Expand Down Expand Up @@ -99,6 +100,7 @@ type Props = {
autoFocus?: boolean,
children?: mixed,
hidden?: boolean,
suppressHydrationWarning?: boolean,
};
type Instance = Element;
type TextInstance = Text;
Expand Down Expand Up @@ -527,10 +529,12 @@ var DOMRenderer = ReactFiberReconciler({
parentContainer: Container,
instance: Instance | TextInstance,
) {
if (instance.nodeType === 1) {
warnForDeletedHydratableElement(parentContainer, (instance: any));
} else {
warnForDeletedHydratableText(parentContainer, (instance: any));
if (__DEV__) {
if (instance.nodeType === 1) {
warnForDeletedHydratableElement(parentContainer, (instance: any));
} else {
warnForDeletedHydratableText(parentContainer, (instance: any));
}
}
},

Expand All @@ -540,10 +544,12 @@ var DOMRenderer = ReactFiberReconciler({
parentInstance: Instance,
instance: Instance | TextInstance,
) {
if (instance.nodeType === 1) {
warnForDeletedHydratableElement(parentInstance, (instance: any));
} else {
warnForDeletedHydratableText(parentInstance, (instance: any));
if (__DEV__ && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
if (instance.nodeType === 1) {
warnForDeletedHydratableElement(parentInstance, (instance: any));
} else {
warnForDeletedHydratableText(parentInstance, (instance: any));
}
}
},

Expand All @@ -552,14 +558,18 @@ var DOMRenderer = ReactFiberReconciler({
type: string,
props: Props,
) {
warnForInsertedHydratedElement(parentContainer, type, props);
if (__DEV__) {
warnForInsertedHydratedElement(parentContainer, type, props);
}
},

didNotFindHydratableContainerTextInstance(
parentContainer: Container,
text: string,
) {
warnForInsertedHydratedText(parentContainer, text);
if (__DEV__) {
warnForInsertedHydratedText(parentContainer, text);
}
},

didNotFindHydratableInstance(
Expand All @@ -569,7 +579,9 @@ var DOMRenderer = ReactFiberReconciler({
type: string,
props: Props,
) {
warnForInsertedHydratedElement(parentInstance, type, props);
if (__DEV__ && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
warnForInsertedHydratedElement(parentInstance, type, props);
}
},

didNotFindHydratableTextInstance(
Expand All @@ -578,7 +590,9 @@ var DOMRenderer = ReactFiberReconciler({
parentInstance: Instance,
text: string,
) {
warnForInsertedHydratedText(parentInstance, text);
if (__DEV__ && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
warnForInsertedHydratedText(parentInstance, text);
}
},

scheduleDeferredCallback: ReactDOMFrameScheduling.rIC,
Expand Down