From 892df464e8ce62959f53412d8e64c70f954b2798 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 2 Aug 2019 00:36:11 +0100 Subject: [PATCH] Move checks inside --- packages/react-reconciler/src/ReactFiberContext.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberContext.js b/packages/react-reconciler/src/ReactFiberContext.js index 0caec6ce8b6d1..7fd763bd5ca11 100644 --- a/packages/react-reconciler/src/ReactFiberContext.js +++ b/packages/react-reconciler/src/ReactFiberContext.js @@ -134,13 +134,11 @@ function hasContextChanged(): boolean { } function isContextProvider(type: Function): boolean { - const childContextTypes = type.childContextTypes; - const hasChildContextTypes = - childContextTypes !== null && childContextTypes !== undefined; if (disableLegacyContext) { return false; } else { - return hasChildContextTypes; + const childContextTypes = type.childContextTypes; + return childContextTypes !== null && childContextTypes !== undefined; } } @@ -154,7 +152,9 @@ function popContext(fiber: Fiber): void { } function popTopLevelContextObject(fiber: Fiber): void { - if (!disableLegacyContext) { + if (disableLegacyContext) { + return; + } else { pop(didPerformWorkStackCursor, fiber); pop(contextStackCursor, fiber); } @@ -165,7 +165,9 @@ function pushTopLevelContextObject( context: Object, didChange: boolean, ): void { - if (!disableLegacyContext) { + if (disableLegacyContext) { + return; + } else { invariant( contextStackCursor.current === emptyContextObject, 'Unexpected context found on stack. ' +