Skip to content

Commit

Permalink
fix: (regression) hook order change is causing React error, fixes #1393
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Nov 14, 2019
1 parent cf716ab commit 6707b4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/internal/getReactStack.js
Expand Up @@ -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;

Expand All @@ -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;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/webpack/patch.js
Expand Up @@ -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': [
Expand Down

0 comments on commit 6707b4b

Please sign in to comment.