Skip to content

Commit

Permalink
[Flight] Delete Server Context (#28225)
Browse files Browse the repository at this point in the history
Server Context was never documented, and has been deprecated in
#27424.

This PR removes it completely, including the implementation code.

Notably, `useContext` is removed from the shared subset, so importing it
from a React Server environment would now should be a build error in
environments that are able to enforce that.

DiffTrain build for commit 4728548.
  • Loading branch information
gaearon committed Feb 5, 2024
1 parent fc7d1d5 commit affeba5
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<36f762822297bdf88d7c307324df43cc>>
* @generated SignedSource<<2841ecb119b8ac2f90b4a6b1a9610f4a>>
*/

"use strict";
Expand All @@ -27,7 +27,6 @@ if (__DEV__) {
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
var REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context");
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
Expand Down Expand Up @@ -104,7 +103,6 @@ if (__DEV__) {
var $$typeofType = type && type.$$typeof;

switch ($$typeofType) {
case REACT_SERVER_CONTEXT_TYPE:
case REACT_CONTEXT_TYPE:
case REACT_FORWARD_REF_TYPE:
case REACT_LAZY_TYPE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<41457e58875ca2b4348c205786f8a603>>
* @generated SignedSource<<0785b258643804110befe2a444659c39>>
*/

"use strict";
Expand All @@ -18,7 +18,6 @@ var REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context"),
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
Expand All @@ -42,7 +41,6 @@ function typeOf(object) {
return object;
default:
switch (((object = object && object.$$typeof), object)) {
case REACT_SERVER_CONTEXT_TYPE:
case REACT_CONTEXT_TYPE:
case REACT_FORWARD_REF_TYPE:
case REACT_LAZY_TYPE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<41457e58875ca2b4348c205786f8a603>>
* @generated SignedSource<<0785b258643804110befe2a444659c39>>
*/

"use strict";
Expand All @@ -18,7 +18,6 @@ var REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context"),
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
Expand All @@ -42,7 +41,6 @@ function typeOf(object) {
return object;
default:
switch (((object = object && object.$$typeof), object)) {
case REACT_SERVER_CONTEXT_TYPE:
case REACT_CONTEXT_TYPE:
case REACT_FORWARD_REF_TYPE:
case REACT_LAZY_TYPE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<fdc597b6fd2e169218abbcc3fbb6bc8c>>
* @generated SignedSource<<3a64021116badb6467add62a13ee5411>>
*/

"use strict";
Expand Down Expand Up @@ -191,7 +191,6 @@ if (__DEV__) {
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
var REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context");
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
Expand Down Expand Up @@ -2705,9 +2704,7 @@ if (__DEV__) {
_currentValue2: null,
_threadCount: 0,
Provider: null,
Consumer: null,
_defaultValue: null,
_globalName: null
Consumer: null
};

function requiredContext(c) {
Expand Down Expand Up @@ -5541,10 +5538,7 @@ if (__DEV__) {
return createChild(returnFiber, unwrapThenable(thenable), lanes);
}

if (
newChild.$$typeof === REACT_CONTEXT_TYPE ||
newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
) {
if (newChild.$$typeof === REACT_CONTEXT_TYPE) {
var context = newChild;
return createChild(
returnFiber,
Expand Down Expand Up @@ -5628,10 +5622,7 @@ if (__DEV__) {
);
}

if (
newChild.$$typeof === REACT_CONTEXT_TYPE ||
newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
) {
if (newChild.$$typeof === REACT_CONTEXT_TYPE) {
var context = newChild;
return updateSlot(
returnFiber,
Expand Down Expand Up @@ -5732,10 +5723,7 @@ if (__DEV__) {
);
}

if (
newChild.$$typeof === REACT_CONTEXT_TYPE ||
newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
) {
if (newChild.$$typeof === REACT_CONTEXT_TYPE) {
var context = newChild;
return updateFromMap(
existingChildren,
Expand Down Expand Up @@ -6442,10 +6430,7 @@ if (__DEV__) {
);
}

if (
newChild.$$typeof === REACT_CONTEXT_TYPE ||
newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
) {
if (newChild.$$typeof === REACT_CONTEXT_TYPE) {
var context = newChild;
return reconcileChildFibersImpl(
returnFiber,
Expand Down Expand Up @@ -7537,10 +7522,7 @@ if (__DEV__) {
// This is a thenable.
var thenable = usable;
return useThenable(thenable);
} else if (
usable.$$typeof === REACT_CONTEXT_TYPE ||
usable.$$typeof === REACT_SERVER_CONTEXT_TYPE
) {
} else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
var context = usable;
return readContext(context);
}
Expand Down Expand Up @@ -15920,9 +15902,7 @@ if (__DEV__) {
var currentValue = valueCursor.current;

{
{
context._currentValue2 = currentValue;
}
context._currentValue2 = currentValue;

{
var currentRenderer2 = renderer2CursorDEV.current;
Expand Down Expand Up @@ -16237,9 +16217,7 @@ if (__DEV__) {
// We'll initialize these at the root.
_currentValue: null,
_currentValue2: null,
_threadCount: 0,
_defaultValue: null,
_globalName: null
_threadCount: 0
};

{
Expand Down Expand Up @@ -25622,7 +25600,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-canary-95ec12839-20240205";
var ReactVersion = "18.3.0-canary-472854820-20240205";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<0830f708091bdd48ea8c30383eaa2377>>
* @generated SignedSource<<44ff806ec3569d53375d403127ca45fb>>
*/

"use strict";
Expand Down Expand Up @@ -38,7 +38,6 @@ var assign = Object.assign,
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
REACT_PROVIDER_TYPE = Symbol.for("react.provider"),
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context"),
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
Expand Down Expand Up @@ -678,9 +677,7 @@ var objectIs = "function" === typeof Object.is ? Object.is : is,
_currentValue2: null,
_threadCount: 0,
Provider: null,
Consumer: null,
_defaultValue: null,
_globalName: null
Consumer: null
};
function pushHostContainer(fiber, nextRootInstance) {
push(rootInstanceStackCursor, nextRootInstance);
Expand Down Expand Up @@ -1696,10 +1693,7 @@ function createChildReconciler(shouldTrackSideEffects) {
);
if ("function" === typeof newChild.then)
return createChild(returnFiber, unwrapThenable(newChild), lanes);
if (
newChild.$$typeof === REACT_CONTEXT_TYPE ||
newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
)
if (newChild.$$typeof === REACT_CONTEXT_TYPE)
return createChild(
returnFiber,
readContextDuringReconcilation(returnFiber, newChild, lanes),
Expand Down Expand Up @@ -1745,10 +1739,7 @@ function createChildReconciler(shouldTrackSideEffects) {
unwrapThenable(newChild),
lanes
);
if (
newChild.$$typeof === REACT_CONTEXT_TYPE ||
newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
)
if (newChild.$$typeof === REACT_CONTEXT_TYPE)
return updateSlot(
returnFiber,
oldFiber,
Expand Down Expand Up @@ -1815,10 +1806,7 @@ function createChildReconciler(shouldTrackSideEffects) {
unwrapThenable(newChild),
lanes
);
if (
newChild.$$typeof === REACT_CONTEXT_TYPE ||
newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
)
if (newChild.$$typeof === REACT_CONTEXT_TYPE)
return updateFromMap(
existingChildren,
returnFiber,
Expand Down Expand Up @@ -2150,10 +2138,7 @@ function createChildReconciler(shouldTrackSideEffects) {
unwrapThenable(newChild),
lanes
);
if (
newChild.$$typeof === REACT_CONTEXT_TYPE ||
newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
)
if (newChild.$$typeof === REACT_CONTEXT_TYPE)
return reconcileChildFibersImpl(
returnFiber,
currentFirstChild,
Expand Down Expand Up @@ -2459,11 +2444,7 @@ function useThenable(thenable) {
function use(usable) {
if (null !== usable && "object" === typeof usable) {
if ("function" === typeof usable.then) return useThenable(usable);
if (
usable.$$typeof === REACT_CONTEXT_TYPE ||
usable.$$typeof === REACT_SERVER_CONTEXT_TYPE
)
return readContext(usable);
if (usable.$$typeof === REACT_CONTEXT_TYPE) return readContext(usable);
}
throw Error("An unsupported type was passed to use(): " + String(usable));
}
Expand Down Expand Up @@ -5049,9 +5030,7 @@ var AbortControllerLocal =
Provider: null,
_currentValue: null,
_currentValue2: null,
_threadCount: 0,
_defaultValue: null,
_globalName: null
_threadCount: 0
};
function createCache() {
return {
Expand Down Expand Up @@ -9171,7 +9150,7 @@ var devToolsConfig$jscomp$inline_1012 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-95ec12839-20240205",
version: "18.3.0-canary-472854820-20240205",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1190 = {
Expand Down Expand Up @@ -9202,7 +9181,7 @@ var internals$jscomp$inline_1190 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-95ec12839-20240205"
reconcilerVersion: "18.3.0-canary-472854820-20240205"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1191 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Loading

0 comments on commit affeba5

Please sign in to comment.