From 6707b4b4473b46b194ef731ce7ae38ab51ebbbbb Mon Sep 17 00:00:00 2001 From: Anton Korzunov Date: Thu, 14 Nov 2019 23:35:31 +1100 Subject: [PATCH] fix: (regression) hook order change is causing React error, fixes #1393 --- src/internal/getReactStack.js | 5 +++-- src/webpack/patch.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/internal/getReactStack.js b/src/internal/getReactStack.js index 71819a7ab..27ba0602b 100644 --- a/src/internal/getReactStack.js +++ b/src/internal/getReactStack.js @@ -34,7 +34,8 @@ const markUpdate = ({ fiber }) => { const mostResentType = resolveType(fiber.type) || fiber.type; if (fiber.elementType === fiber.type) { - fiber.elementType = mostResentType; + // DO NOT update elementType - or will not be able to catch un update + // fiber.elementType = mostResentType; } fiber.type = mostResentType; @@ -44,7 +45,7 @@ const markUpdate = ({ fiber }) => { fiber.alternate.type = fiber.type; // elementType might not exists in older react versions if ('elementType' in fiber.alternate) { - fiber.alternate.elementType = fiber.elementType; + // fiber.alternate.elementType = fiber.elementType; } } diff --git a/src/webpack/patch.js b/src/webpack/patch.js index f83d33e09..ee5624dc5 100644 --- a/src/webpack/patch.js +++ b/src/webpack/patch.js @@ -26,12 +26,13 @@ const injectionStart = { }; const additional = { + '16.10-update': [ - '( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))', + 'current$$1.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))', '(hotCompareElements(current$$1.elementType, element.type, hotUpdateChild(current$$1), current$$1.type)))' ], '16.9-update': [ - '(\n // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))', + 'current$$1.elementType === element.type || (\n // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))', '(hotCompareElements(current$$1.elementType, element.type, hotUpdateChild(current$$1), current$$1.type)))' ], '16.6-update': [