Skip to content

Commit 6707b4b

Browse files
committed
fix: (regression) hook order change is causing React error, fixes #1393
1 parent cf716ab commit 6707b4b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/internal/getReactStack.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ const markUpdate = ({ fiber }) => {
3434

3535
const mostResentType = resolveType(fiber.type) || fiber.type;
3636
if (fiber.elementType === fiber.type) {
37-
fiber.elementType = mostResentType;
37+
// DO NOT update elementType - or will not be able to catch un update
38+
// fiber.elementType = mostResentType;
3839
}
3940
fiber.type = mostResentType;
4041

@@ -44,7 +45,7 @@ const markUpdate = ({ fiber }) => {
4445
fiber.alternate.type = fiber.type;
4546
// elementType might not exists in older react versions
4647
if ('elementType' in fiber.alternate) {
47-
fiber.alternate.elementType = fiber.elementType;
48+
// fiber.alternate.elementType = fiber.elementType;
4849
}
4950
}
5051

src/webpack/patch.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ const injectionStart = {
2626
};
2727

2828
const additional = {
29+
2930
'16.10-update': [
30-
'( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))',
31+
'current$$1.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))',
3132
'(hotCompareElements(current$$1.elementType, element.type, hotUpdateChild(current$$1), current$$1.type)))'
3233
],
3334
'16.9-update': [
34-
'(\n // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))',
35+
'current$$1.elementType === element.type || (\n // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))',
3536
'(hotCompareElements(current$$1.elementType, element.type, hotUpdateChild(current$$1), current$$1.type)))'
3637
],
3738
'16.6-update': [

0 commit comments

Comments
 (0)