@@ -463,6 +463,7 @@ function iterativelyCommitBeforeMutationEffects_begin() { |
463 | 463 | (fiber.subtreeFlags & BeforeMutationMask) !== NoFlags && |
464 | 464 | child !== null |
465 | 465 | ) { |
| 466 | + warnIfWrongReturnPointer(fiber, child); |
466 | 467 | nextEffect = child; |
467 | 468 | } else { |
468 | 469 | iterativelyCommitBeforeMutationEffects_complete(); |
@@ -496,6 +497,7 @@ function iterativelyCommitBeforeMutationEffects_complete() { |
496 | 497 |
|
497 | 498 | const sibling = fiber.sibling; |
498 | 499 | if (sibling !== null) { |
| 500 | + warnIfWrongReturnPointer(fiber.return, sibling); |
499 | 501 | nextEffect = sibling; |
500 | 502 | return; |
501 | 503 | } |
@@ -713,6 +715,7 @@ function iterativelyCommitMutationEffects_begin( |
713 | 715 |
|
714 | 716 | const child = fiber.child; |
715 | 717 | if ((fiber.subtreeFlags & MutationMask) !== NoFlags && child !== null) { |
| 718 | + warnIfWrongReturnPointer(fiber, child); |
716 | 719 | nextEffect = child; |
717 | 720 | } else { |
718 | 721 | iterativelyCommitMutationEffects_complete(root, renderPriorityLevel); |
@@ -751,6 +754,7 @@ function iterativelyCommitMutationEffects_complete( |
751 | 754 |
|
752 | 755 | const sibling = fiber.sibling; |
753 | 756 | if (sibling !== null) { |
| 757 | + warnIfWrongReturnPointer(fiber.return, sibling); |
754 | 758 | nextEffect = sibling; |
755 | 759 | return; |
756 | 760 | } |
@@ -1172,12 +1176,14 @@ function iterativelyCommitLayoutEffects_begin( |
1172 | 1176 | } |
1173 | 1177 | const sibling = finishedWork.sibling; |
1174 | 1178 | if (sibling !== null) { |
| 1179 | + warnIfWrongReturnPointer(finishedWork.return, sibling); |
1175 | 1180 | nextEffect = sibling; |
1176 | 1181 | } else { |
1177 | 1182 | nextEffect = finishedWork.return; |
1178 | 1183 | iterativelyCommitLayoutEffects_complete(subtreeRoot, finishedRoot); |
1179 | 1184 | } |
1180 | 1185 | } else { |
| 1186 | + warnIfWrongReturnPointer(finishedWork, firstChild); |
1181 | 1187 | nextEffect = firstChild; |
1182 | 1188 | } |
1183 | 1189 | } else { |
@@ -1224,6 +1230,7 @@ function iterativelyCommitLayoutEffects_complete( |
1224 | 1230 |
|
1225 | 1231 | const sibling = fiber.sibling; |
1226 | 1232 | if (sibling !== null) { |
| 1233 | + warnIfWrongReturnPointer(fiber.return, sibling); |
1227 | 1234 | nextEffect = sibling; |
1228 | 1235 | return; |
1229 | 1236 | } |
@@ -1757,12 +1764,14 @@ function iterativelyCommitPassiveMountEffects_begin( |
1757 | 1764 | } |
1758 | 1765 | const sibling = fiber.sibling; |
1759 | 1766 | if (sibling !== null) { |
| 1767 | + warnIfWrongReturnPointer(fiber.return, sibling); |
1760 | 1768 | nextEffect = sibling; |
1761 | 1769 | } else { |
1762 | 1770 | nextEffect = fiber.return; |
1763 | 1771 | iterativelyCommitPassiveMountEffects_complete(subtreeRoot, root); |
1764 | 1772 | } |
1765 | 1773 | } else { |
| 1774 | + warnIfWrongReturnPointer(fiber, firstChild); |
1766 | 1775 | nextEffect = firstChild; |
1767 | 1776 | } |
1768 | 1777 | } else { |
@@ -1808,6 +1817,7 @@ function iterativelyCommitPassiveMountEffects_complete( |
1808 | 1817 |
|
1809 | 1818 | const sibling = fiber.sibling; |
1810 | 1819 | if (sibling !== null) { |
| 1820 | + warnIfWrongReturnPointer(fiber.return, sibling); |
1811 | 1821 | nextEffect = sibling; |
1812 | 1822 | return; |
1813 | 1823 | } |
@@ -1886,6 +1896,7 @@ function iterativelyCommitPassiveUnmountEffects_begin() { |
1886 | 1896 | } |
1887 | 1897 |
|
1888 | 1898 | if ((fiber.subtreeFlags & PassiveMask) !== NoFlags && child !== null) { |
| 1899 | + warnIfWrongReturnPointer(fiber, child); |
1889 | 1900 | nextEffect = child; |
1890 | 1901 | } else { |
1891 | 1902 | iterativelyCommitPassiveUnmountEffects_complete(); |
@@ -1904,6 +1915,7 @@ function iterativelyCommitPassiveUnmountEffects_complete() { |
1904 | 1915 |
|
1905 | 1916 | const sibling = fiber.sibling; |
1906 | 1917 | if (sibling !== null) { |
| 1918 | + warnIfWrongReturnPointer(fiber.return, sibling); |
1907 | 1919 | nextEffect = sibling; |
1908 | 1920 | return; |
1909 | 1921 | } |
@@ -1941,6 +1953,7 @@ function iterativelyCommitPassiveUnmountEffectsInsideOfDeletedTree_begin( |
1941 | 1953 | const fiber = nextEffect; |
1942 | 1954 | const child = fiber.child; |
1943 | 1955 | if ((fiber.subtreeFlags & PassiveStatic) !== NoFlags && child !== null) { |
| 1956 | + warnIfWrongReturnPointer(fiber, child); |
1944 | 1957 | nextEffect = child; |
1945 | 1958 | } else { |
1946 | 1959 | iterativelyCommitPassiveUnmountEffectsInsideOfDeletedTree_complete( |
@@ -1968,6 +1981,7 @@ function iterativelyCommitPassiveUnmountEffectsInsideOfDeletedTree_complete( |
1968 | 1981 |
|
1969 | 1982 | const sibling = fiber.sibling; |
1970 | 1983 | if (sibling !== null) { |
| 1984 | + warnIfWrongReturnPointer(fiber.return, sibling); |
1971 | 1985 | nextEffect = sibling; |
1972 | 1986 | return; |
1973 | 1987 | } |
@@ -3178,3 +3192,16 @@ function invokeEffectsInDev( |
3178 | 3192 | } |
3179 | 3193 | } |
3180 | 3194 | } |
| 3195 | + |
| 3196 | +let didWarnWrongReturnPointer = false; |
| 3197 | +function warnIfWrongReturnPointer(returnFiber, child) { |
| 3198 | + if (__DEV__) { |
| 3199 | + if (!didWarnWrongReturnPointer && child.return !== returnFiber) { |
| 3200 | + didWarnWrongReturnPointer = true; |
| 3201 | + console.error( |
| 3202 | + 'Internal React error: Return pointer is inconsistent ' + |
| 3203 | + 'with parent.', |
| 3204 | + ); |
| 3205 | + } |
| 3206 | + } |
| 3207 | +} |