Skip to content

Commit d1d0508

Browse files
committed
Rename the react.element symbol to react.transitional.element (#28813)
We have changed the shape (and the runtime) of React Elements. To help avoid precompiled or inlined JSX having subtle breakages or deopting hidden classes, I renamed the symbol so that we can early error if private implementation details are used or mismatching versions are used. Why "transitional"? Well, because this is not the last time we'll change the shape. This is just a stepping stone to removing the `ref` field on the elements in the next version so we'll likely have to do it again. DiffTrain build for [3b551c8](3b551c8)
1 parent 5d6e662 commit d1d0508

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+418
-333
lines changed

compiled/facebook-www/JSXDEVRuntime-dev.classic.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,25 @@ if (__DEV__) {
1818

1919
var React = require('react');
2020

21-
// ATTENTION
21+
// Re-export dynamic flags from the www version.
22+
var dynamicFeatureFlags = require('ReactFeatureFlags');
23+
24+
var enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
25+
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
26+
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
27+
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
28+
disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses;
29+
// On WWW, false is used for a new modern build.
30+
// because JSX is an extremely hot path.
31+
32+
var disableStringRefs = false;
33+
2234
// When adding new symbols to this file,
2335
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
2436
// The Symbol used to tag the ReactElement-like types.
25-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
37+
38+
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for('react.element');
39+
var REACT_ELEMENT_TYPE = REACT_LEGACY_ELEMENT_TYPE;
2640
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
2741
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
2842
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
@@ -93,19 +107,6 @@ function printWarning(level, format, args) {
93107
}
94108
}
95109

96-
// Re-export dynamic flags from the www version.
97-
var dynamicFeatureFlags = require('ReactFeatureFlags');
98-
99-
var enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
100-
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
101-
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
102-
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
103-
disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses;
104-
// On WWW, false is used for a new modern build.
105-
// because JSX is an extremely hot path.
106-
107-
var disableStringRefs = false;
108-
109110
function getWrappedName$1(outerType, innerType, wrapperName) {
110111
var displayName = outerType.displayName;
111112

@@ -1026,7 +1027,7 @@ function elementRefGetterWithDeprecationWarning() {
10261027
/**
10271028
* Factory method to create a new React element. This no longer adheres to
10281029
* the class pattern, so do not use new to call it. Also, instanceof check
1029-
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
1030+
* will not work. Instead test $$typeof field against Symbol.for('react.transitional.element') to check
10301031
* if something is a React Element.
10311032
*
10321033
* @param {*} type

compiled/facebook-www/JSXDEVRuntime-dev.modern.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,25 @@ if (__DEV__) {
1818

1919
var React = require('react');
2020

21-
// ATTENTION
21+
// Re-export dynamic flags from the www version.
22+
var dynamicFeatureFlags = require('ReactFeatureFlags');
23+
24+
var enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
25+
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
26+
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
27+
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
28+
disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses;
29+
// On WWW, true is used for a new modern build.
30+
// because JSX is an extremely hot path.
31+
32+
var disableStringRefs = false;
33+
2234
// When adding new symbols to this file,
2335
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
2436
// The Symbol used to tag the ReactElement-like types.
25-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
37+
38+
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for('react.element');
39+
var REACT_ELEMENT_TYPE = REACT_LEGACY_ELEMENT_TYPE;
2640
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
2741
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
2842
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
@@ -93,19 +107,6 @@ function printWarning(level, format, args) {
93107
}
94108
}
95109

96-
// Re-export dynamic flags from the www version.
97-
var dynamicFeatureFlags = require('ReactFeatureFlags');
98-
99-
var enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
100-
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
101-
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
102-
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
103-
disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses;
104-
// On WWW, true is used for a new modern build.
105-
// because JSX is an extremely hot path.
106-
107-
var disableStringRefs = false;
108-
109110
function getWrappedName$1(outerType, innerType, wrapperName) {
110111
var displayName = outerType.displayName;
111112

@@ -1029,7 +1030,7 @@ function elementRefGetterWithDeprecationWarning() {
10291030
/**
10301031
* Factory method to create a new React element. This no longer adheres to
10311032
* the class pattern, so do not use new to call it. Also, instanceof check
1032-
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
1033+
* will not work. Instead test $$typeof field against Symbol.for('react.transitional.element') to check
10331034
* if something is a React Element.
10341035
*
10351036
* @param {*} type

compiled/facebook-www/JSXDEVRuntime-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
"use strict";
14-
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
1514
require("ReactFeatureFlags");
15+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
1616
exports.Fragment = REACT_FRAGMENT_TYPE;
1717
exports.jsxDEV = void 0;

compiled/facebook-www/JSXDEVRuntime-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
"use strict";
14-
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
1514
require("ReactFeatureFlags");
15+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
1616
exports.Fragment = REACT_FRAGMENT_TYPE;
1717
exports.jsxDEV = void 0;

compiled/facebook-www/JSXDEVRuntime-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
"use strict";
14-
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
1514
require("ReactFeatureFlags");
15+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
1616
exports.Fragment = REACT_FRAGMENT_TYPE;
1717
exports.jsxDEV = void 0;

compiled/facebook-www/JSXDEVRuntime-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
"use strict";
14-
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
1514
require("ReactFeatureFlags");
15+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
1616
exports.Fragment = REACT_FRAGMENT_TYPE;
1717
exports.jsxDEV = void 0;

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
db913d8e17db25045e0518f3621f1640f2390525
1+
3b551c82844bcfde51f0febb8e42c1a0d777df2c

compiled/facebook-www/React-dev.classic.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,28 @@ if (
2525
) {
2626
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2727
}
28-
var ReactVersion = '19.0.0-www-classic-29916c01';
28+
var ReactVersion = '19.0.0-www-classic-ece5ea17';
29+
30+
// Re-export dynamic flags from the www version.
31+
var dynamicFeatureFlags = require('ReactFeatureFlags');
32+
33+
var enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
34+
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
35+
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
36+
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
37+
disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses;
38+
// On WWW, false is used for a new modern build.
39+
// because JSX is an extremely hot path.
40+
41+
var disableStringRefs = false;
42+
var disableLegacyMode = false;
2943

30-
// ATTENTION
3144
// When adding new symbols to this file,
3245
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
3346
// The Symbol used to tag the ReactElement-like types.
34-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
47+
48+
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for('react.element');
49+
var REACT_ELEMENT_TYPE = REACT_LEGACY_ELEMENT_TYPE;
3550
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
3651
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
3752
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
@@ -422,20 +437,6 @@ function checkPropStringCoercion(value, propName) {
422437
}
423438
}
424439

425-
// Re-export dynamic flags from the www version.
426-
var dynamicFeatureFlags = require('ReactFeatureFlags');
427-
428-
var enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
429-
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
430-
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
431-
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
432-
disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses;
433-
// On WWW, false is used for a new modern build.
434-
// because JSX is an extremely hot path.
435-
436-
var disableStringRefs = false;
437-
var disableLegacyMode = false;
438-
439440
function getWrappedName$1(outerType, innerType, wrapperName) {
440441
var displayName = outerType.displayName;
441442

@@ -1313,7 +1314,7 @@ function elementRefGetterWithDeprecationWarning() {
13131314
/**
13141315
* Factory method to create a new React element. This no longer adheres to
13151316
* the class pattern, so do not use new to call it. Also, instanceof check
1316-
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
1317+
* will not work. Instead test $$typeof field against Symbol.for('react.transitional.element') to check
13171318
* if something is a React Element.
13181319
*
13191320
* @param {*} type

compiled/facebook-www/React-dev.modern.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,28 @@ if (
2525
) {
2626
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2727
}
28-
var ReactVersion = '19.0.0-www-modern-16b8232b';
28+
var ReactVersion = '19.0.0-www-modern-367021cf';
29+
30+
// Re-export dynamic flags from the www version.
31+
var dynamicFeatureFlags = require('ReactFeatureFlags');
32+
33+
var enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
34+
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
35+
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
36+
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
37+
disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses;
38+
// On WWW, true is used for a new modern build.
39+
// because JSX is an extremely hot path.
40+
41+
var disableStringRefs = false;
42+
var disableLegacyMode = true;
2943

30-
// ATTENTION
3144
// When adding new symbols to this file,
3245
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
3346
// The Symbol used to tag the ReactElement-like types.
34-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
47+
48+
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for('react.element');
49+
var REACT_ELEMENT_TYPE = REACT_LEGACY_ELEMENT_TYPE;
3550
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
3651
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
3752
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
@@ -422,20 +437,6 @@ function checkPropStringCoercion(value, propName) {
422437
}
423438
}
424439

425-
// Re-export dynamic flags from the www version.
426-
var dynamicFeatureFlags = require('ReactFeatureFlags');
427-
428-
var enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
429-
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
430-
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
431-
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
432-
disableDefaultPropsExceptForClasses = dynamicFeatureFlags.disableDefaultPropsExceptForClasses;
433-
// On WWW, true is used for a new modern build.
434-
// because JSX is an extremely hot path.
435-
436-
var disableStringRefs = false;
437-
var disableLegacyMode = true;
438-
439440
function getWrappedName$1(outerType, innerType, wrapperName) {
440441
var displayName = outerType.displayName;
441442

@@ -1316,7 +1317,7 @@ function elementRefGetterWithDeprecationWarning() {
13161317
/**
13171318
* Factory method to create a new React element. This no longer adheres to
13181319
* the class pattern, so do not use new to call it. Also, instanceof check
1319-
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
1320+
* will not work. Instead test $$typeof field against Symbol.for('react.transitional.element') to check
13201321
* if something is a React Element.
13211322
*
13221323
* @param {*} type

compiled/facebook-www/React-prod.classic.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
*/
1212

1313
"use strict";
14-
var REACT_ELEMENT_TYPE = Symbol.for("react.element"),
14+
var dynamicFeatureFlags = require("ReactFeatureFlags"),
15+
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
16+
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
17+
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
18+
disableDefaultPropsExceptForClasses =
19+
dynamicFeatureFlags.disableDefaultPropsExceptForClasses,
20+
REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
1521
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
1622
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
1723
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
@@ -81,19 +87,13 @@ pureComponentPrototype.constructor = PureComponent;
8187
assign(pureComponentPrototype, Component.prototype);
8288
pureComponentPrototype.isPureReactComponent = !0;
8389
var isArrayImpl = Array.isArray,
84-
dynamicFeatureFlags = require("ReactFeatureFlags"),
85-
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
86-
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
87-
enableRefAsProp = dynamicFeatureFlags.enableRefAsProp,
88-
disableDefaultPropsExceptForClasses =
89-
dynamicFeatureFlags.disableDefaultPropsExceptForClasses,
9090
ReactSharedInternals = { H: null, C: null, T: null, owner: null },
9191
hasOwnProperty = Object.prototype.hasOwnProperty;
9292
function ReactElement(type, key, _ref, self, source, owner, props) {
9393
enableRefAsProp &&
9494
((_ref = props.ref), (_ref = void 0 !== _ref ? _ref : null));
9595
return {
96-
$$typeof: REACT_ELEMENT_TYPE,
96+
$$typeof: REACT_LEGACY_ELEMENT_TYPE,
9797
type: type,
9898
key: key,
9999
ref: _ref,
@@ -152,7 +152,7 @@ function isValidElement(object) {
152152
return (
153153
"object" === typeof object &&
154154
null !== object &&
155-
object.$$typeof === REACT_ELEMENT_TYPE
155+
object.$$typeof === REACT_LEGACY_ELEMENT_TYPE
156156
);
157157
}
158158
function coerceStringRef(mixedRef, owner, type) {
@@ -249,7 +249,7 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
249249
break;
250250
case "object":
251251
switch (children.$$typeof) {
252-
case REACT_ELEMENT_TYPE:
252+
case REACT_LEGACY_ELEMENT_TYPE:
253253
case REACT_PORTAL_TYPE:
254254
invokeCallback = !0;
255255
break;
@@ -695,4 +695,4 @@ exports.useSyncExternalStore = function (
695695
exports.useTransition = function () {
696696
return ReactSharedInternals.H.useTransition();
697697
};
698-
exports.version = "19.0.0-www-classic-c379aa62";
698+
exports.version = "19.0.0-www-classic-4c7400c8";

0 commit comments

Comments
 (0)