Skip to content

Commit

Permalink
Disable ServerContext in canary (#27474)
Browse files Browse the repository at this point in the history
We previously added a warning in #27424. This just removes it from
canary/stable channels but keeps it in experimental for now.

DiffTrain build for [1fc58281af73ca4507c41d53a3e08dc2038b0c1f](facebook/react@1fc5828)
  • Loading branch information
jerrydev0927 committed Oct 11, 2023
1 parent 813365c commit be04453
Show file tree
Hide file tree
Showing 31 changed files with 69 additions and 602 deletions.
6 changes: 0 additions & 6 deletions compiled/facebook-www/JSXDEVRuntime-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
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 @@ -255,11 +254,6 @@ function getComponentNameFromType(type) {
return null;
}
}

case REACT_SERVER_CONTEXT_TYPE: {
var context2 = type;
return (context2.displayName || context2._globalName) + ".Provider";
}
}
}

Expand Down
6 changes: 0 additions & 6 deletions compiled/facebook-www/JSXDEVRuntime-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
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 @@ -255,11 +254,6 @@ function getComponentNameFromType(type) {
return null;
}
}

case REACT_SERVER_CONTEXT_TYPE: {
var context2 = type;
return (context2.displayName || context2._globalName) + ".Provider";
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
537228f9fd703d18bea1f6d20fa0e5006b795c42
1fc58281af73ca4507c41d53a3e08dc2038b0c1f
99 changes: 1 addition & 98 deletions compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-classic-01108d4a";
var ReactVersion = "18.3.0-www-classic-d874e0af";

// ATTENTION
// When adding new symbols to this file,
Expand All @@ -40,7 +40,6 @@ var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
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 All @@ -52,9 +51,6 @@ var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
var REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden");
var REACT_CACHE_TYPE = Symbol.for("react.cache");
var REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker");
var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for(
"react.default_value"
);
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = "@@iterator";
function getIteratorFn(maybeIterable) {
Expand Down Expand Up @@ -584,11 +580,6 @@ function getComponentNameFromType(type) {
return null;
}
}

case REACT_SERVER_CONTEXT_TYPE: {
var context2 = type;
return (context2.displayName || context2._globalName) + ".Provider";
}
}
}

Expand Down Expand Up @@ -2177,8 +2168,6 @@ function setExtraStackFrame(stack) {
};
}

var ContextRegistry = {};

var ReactSharedInternals = {
ReactCurrentDispatcher: ReactCurrentDispatcher$1,
ReactCurrentCache: ReactCurrentCache,
Expand All @@ -2191,10 +2180,6 @@ var ReactSharedInternals = {
ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;
}

{
ReactSharedInternals.ContextRegistry = ContextRegistry;
}

var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
var prefix;
function describeBuiltInComponentFrame(name, source, ownerFn) {
Expand Down Expand Up @@ -2947,87 +2932,6 @@ function cloneElementWithValidation(element, props, children) {
return newElement;
}

function createServerContext(globalName, defaultValue) {
{
error(
"Server Context is deprecated and will soon be removed. " +
"It was never documented and we have found it not to be useful " +
"enough to warrant the downside it imposes on all apps."
);
}

var wasDefined = true;

if (!ContextRegistry[globalName]) {
wasDefined = false;
var _context = {
$$typeof: REACT_SERVER_CONTEXT_TYPE,
// As a workaround to support multiple concurrent renderers, we categorize
// some renderers as primary and others as secondary. We only expect
// there to be two concurrent renderers at most: React Native (primary) and
// Fabric (secondary); React DOM (primary) and React ART (secondary).
// Secondary renderers store their context values on separate fields.
_currentValue: defaultValue,
_currentValue2: defaultValue,
_defaultValue: defaultValue,
// Used to track how many concurrent renderers this context currently
// supports within in a single renderer. Such as parallel server rendering.
_threadCount: 0,
// These are circular
Provider: null,
Consumer: null,
_globalName: globalName
};
_context.Provider = {
$$typeof: REACT_PROVIDER_TYPE,
_context: _context
};

{
var hasWarnedAboutUsingConsumer;
_context._currentRenderer = null;
_context._currentRenderer2 = null;
Object.defineProperties(_context, {
Consumer: {
get: function () {
if (!hasWarnedAboutUsingConsumer) {
error("Consumer pattern is not supported by ReactServerContext");

hasWarnedAboutUsingConsumer = true;
}

return null;
}
}
});
}

ContextRegistry[globalName] = _context;
}

var context = ContextRegistry[globalName];

if (context._defaultValue === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED) {
context._defaultValue = defaultValue;

if (
context._currentValue === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED
) {
context._currentValue = defaultValue;
}

if (
context._currentValue2 === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED
) {
context._currentValue2 = defaultValue;
}
} else if (wasDefined) {
throw new Error("ServerContext: " + globalName + " already defined");
}

return context;
}

function startTransition(scope, options) {
var prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = {};
Expand Down Expand Up @@ -4165,7 +4069,6 @@ exports.createContext = createContext;
exports.createElement = createElement;
exports.createFactory = createFactory;
exports.createRef = createRef;
exports.createServerContext = createServerContext;
exports.experimental_useEffectEvent = useEffectEvent;
exports.forwardRef = forwardRef;
exports.isValidElement = isValidElement$1;
Expand Down
99 changes: 1 addition & 98 deletions compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-modern-6dbff8b1";
var ReactVersion = "18.3.0-www-modern-872bdfba";

// ATTENTION
// When adding new symbols to this file,
Expand All @@ -40,7 +40,6 @@ var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
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 All @@ -52,9 +51,6 @@ var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
var REACT_LEGACY_HIDDEN_TYPE = Symbol.for("react.legacy_hidden");
var REACT_CACHE_TYPE = Symbol.for("react.cache");
var REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker");
var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for(
"react.default_value"
);
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = "@@iterator";
function getIteratorFn(maybeIterable) {
Expand Down Expand Up @@ -584,11 +580,6 @@ function getComponentNameFromType(type) {
return null;
}
}

case REACT_SERVER_CONTEXT_TYPE: {
var context2 = type;
return (context2.displayName || context2._globalName) + ".Provider";
}
}
}

Expand Down Expand Up @@ -2177,8 +2168,6 @@ function setExtraStackFrame(stack) {
};
}

var ContextRegistry = {};

var ReactSharedInternals = {
ReactCurrentDispatcher: ReactCurrentDispatcher$1,
ReactCurrentCache: ReactCurrentCache,
Expand All @@ -2191,10 +2180,6 @@ var ReactSharedInternals = {
ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;
}

{
ReactSharedInternals.ContextRegistry = ContextRegistry;
}

var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
var prefix;
function describeBuiltInComponentFrame(name, source, ownerFn) {
Expand Down Expand Up @@ -2913,87 +2898,6 @@ function cloneElementWithValidation(element, props, children) {
return newElement;
}

function createServerContext(globalName, defaultValue) {
{
error(
"Server Context is deprecated and will soon be removed. " +
"It was never documented and we have found it not to be useful " +
"enough to warrant the downside it imposes on all apps."
);
}

var wasDefined = true;

if (!ContextRegistry[globalName]) {
wasDefined = false;
var _context = {
$$typeof: REACT_SERVER_CONTEXT_TYPE,
// As a workaround to support multiple concurrent renderers, we categorize
// some renderers as primary and others as secondary. We only expect
// there to be two concurrent renderers at most: React Native (primary) and
// Fabric (secondary); React DOM (primary) and React ART (secondary).
// Secondary renderers store their context values on separate fields.
_currentValue: defaultValue,
_currentValue2: defaultValue,
_defaultValue: defaultValue,
// Used to track how many concurrent renderers this context currently
// supports within in a single renderer. Such as parallel server rendering.
_threadCount: 0,
// These are circular
Provider: null,
Consumer: null,
_globalName: globalName
};
_context.Provider = {
$$typeof: REACT_PROVIDER_TYPE,
_context: _context
};

{
var hasWarnedAboutUsingConsumer;
_context._currentRenderer = null;
_context._currentRenderer2 = null;
Object.defineProperties(_context, {
Consumer: {
get: function () {
if (!hasWarnedAboutUsingConsumer) {
error("Consumer pattern is not supported by ReactServerContext");

hasWarnedAboutUsingConsumer = true;
}

return null;
}
}
});
}

ContextRegistry[globalName] = _context;
}

var context = ContextRegistry[globalName];

if (context._defaultValue === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED) {
context._defaultValue = defaultValue;

if (
context._currentValue === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED
) {
context._currentValue = defaultValue;
}

if (
context._currentValue2 === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED
) {
context._currentValue2 = defaultValue;
}
} else if (wasDefined) {
throw new Error("ServerContext: " + globalName + " already defined");
}

return context;
}

function startTransition(scope, options) {
var prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = {};
Expand Down Expand Up @@ -4129,7 +4033,6 @@ exports.cloneElement = cloneElement;
exports.createContext = createContext;
exports.createElement = createElement;
exports.createRef = createRef;
exports.createServerContext = createServerContext;
exports.experimental_useEffectEvent = useEffectEvent;
exports.forwardRef = forwardRef;
exports.isValidElement = isValidElement$1;
Expand Down
Loading

0 comments on commit be04453

Please sign in to comment.