Skip to content

Commit

Permalink
Move mismatch text hydration warning to the new hooks
Browse files Browse the repository at this point in the history
This lets us ignore this call when we have parent props available and
the suppression flag is set.
  • Loading branch information
sebmarkbage committed Oct 6, 2017
1 parent 71e4d77 commit b3dfd2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/renderers/dom/fiber/ReactDOMFiberComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1140,12 +1140,13 @@ var ReactDOMFiberComponent = {

diffHydratedText(textNode: Text, text: string): boolean {
const isDifferent = textNode.nodeValue !== text;
return isDifferent;
},

warnForUnmatchedText(textNode: Text, text: string) {
if (__DEV__) {
if (isDifferent) {
warnForTextDifference(textNode.nodeValue, text);
}
warnForTextDifference(textNode.nodeValue, text);
}
return isDifferent;
},

warnForDeletedHydratableElement(
Expand Down
5 changes: 4 additions & 1 deletion src/renderers/dom/fiber/ReactDOMFiberEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var {
updateProperties,
diffHydratedProperties,
diffHydratedText,
warnForUnmatchedText,
warnForDeletedHydratableElement,
warnForDeletedHydratableText,
warnForInsertedHydratedElement,
Expand Down Expand Up @@ -531,6 +532,7 @@ var DOMRenderer = ReactFiberReconciler({
text: string,
) {
if (__DEV__) {
warnForUnmatchedText(textInstance, text);
}
},

Expand All @@ -541,7 +543,8 @@ var DOMRenderer = ReactFiberReconciler({
textInstance: TextInstance,
text: string,
) {
if (__DEV__) {
if (__DEV__ && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
warnForUnmatchedText(textInstance, text);
}
},

Expand Down

0 comments on commit b3dfd2d

Please sign in to comment.