Skip to content

Commit 0688f2d

Browse files
committed
Flag the change
1 parent 63e2343 commit 0688f2d

12 files changed

+26
-6
lines changed

packages/react-dom/src/__tests__/ReactComponent-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ describe('ReactComponent', () => {
612612
);
613613
});
614614

615+
// @gate renameElementSymbol
615616
it('throws if a legacy element is used as a child', async () => {
616617
const inlinedElement = {
617618
$$typeof: Symbol.for('react.element'),

packages/react-dom/src/__tests__/ReactDOMOption-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,12 @@ describe('ReactDOMOption', () => {
134134
}).rejects.toThrow('Objects are not valid as a React child');
135135
});
136136

137+
// @gate www
137138
it('should support element-ish child', async () => {
138139
// This is similar to <fbt>.
139140
// We don't toString it because you must instead provide a value prop.
140141
const obj = {
141-
$$typeof: Symbol.for('react.transitional.element'),
142+
$$typeof: Symbol.for('react.element'),
142143
type: props => props.content,
143144
ref: null,
144145
key: null,

packages/react-dom/src/__tests__/refs-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,14 @@ describe('ref swapping', () => {
382382
}).rejects.toThrow('Expected ref to be a function');
383383
});
384384

385-
// @gate !enableRefAsProp
385+
// @gate !enableRefAsProp && www
386386
it('undefined ref on manually inlined React element triggers error', async () => {
387387
const container = document.createElement('div');
388388
const root = ReactDOMClient.createRoot(container);
389389
await expect(async () => {
390390
await act(() => {
391391
root.render({
392-
$$typeof: Symbol.for('react.transitional.element'),
392+
$$typeof: Symbol.for('react.element'),
393393
type: 'div',
394394
props: {
395395
ref: undefined,

packages/shared/ReactFeatureFlags.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ export const transitionLaneExpirationMs = 5000;
143143

144144
// const __NEXT_MAJOR__ = __EXPERIMENTAL__;
145145

146+
// Renames the internal symbol for elements since they have changed signature/constructor
147+
export const renameElementSymbol = true;
148+
146149
// Removes legacy style context
147150
export const disableLegacyContext = true;
148151

packages/shared/ReactSymbols.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
* @flow
88
*/
99

10+
import {renameElementSymbol} from 'shared/ReactFeatureFlags';
11+
1012
// ATTENTION
1113
// When adding new symbols to this file,
1214
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
1315

1416
// The Symbol used to tag the ReactElement-like types.
15-
export const REACT_ELEMENT_TYPE: symbol = Symbol.for(
16-
'react.transitional.element',
17-
);
1817
export const REACT_LEGACY_ELEMENT_TYPE: symbol = Symbol.for('react.element');
18+
export const REACT_ELEMENT_TYPE: symbol = renameElementSymbol
19+
? Symbol.for('react.transitional.element')
20+
: REACT_LEGACY_ELEMENT_TYPE;
1921
export const REACT_PORTAL_TYPE: symbol = Symbol.for('react.portal');
2022
export const REACT_FRAGMENT_TYPE: symbol = Symbol.for('react.fragment');
2123
export const REACT_STRICT_MODE_TYPE: symbol = Symbol.for('react.strict_mode');

packages/shared/__tests__/ReactSymbols-test.internal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('ReactSymbols', () => {
2323
});
2424
};
2525

26+
// @gate renameElementSymbol
2627
it('Symbol values should be unique', () => {
2728
expectToBeUnique(Object.entries(require('shared/ReactSymbols')));
2829
});

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export const enableLegacyFBSupport = false;
6969
export const enableFilterEmptyStringAttributesDOM = true;
7070
export const enableGetInspectorDataForInstanceInProduction = true;
7171

72+
export const renameElementSymbol = false;
73+
7274
export const enableRetryLaneExpiration = false;
7375
export const retryLaneExpirationMs = 5000;
7476
export const syncLaneExpirationMs = 250;

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
104104
export const passChildrenWhenCloningPersistedNodes = false;
105105
export const enableEarlyReturnForPropDiffing = false;
106106

107+
export const renameElementSymbol = true;
108+
107109
// Profiling Only
108110
export const enableProfilerTimer = __PROFILE__;
109111
export const enableProfilerCommitHooks = __PROFILE__;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export const enableServerComponentLogs = true;
7979
export const enableInfiniteRenderLoopDetection = false;
8080
export const enableEarlyReturnForPropDiffing = false;
8181

82+
export const renameElementSymbol = true;
83+
8284
// TODO: This must be in sync with the main ReactFeatureFlags file because
8385
// the Test Renderer's value must be the same as the one used by the
8486
// react package.

packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,7 @@ export const disableDOMTestUtils = false;
9090
export const disableDefaultPropsExceptForClasses = false;
9191
export const enableEarlyReturnForPropDiffing = false;
9292

93+
export const renameElementSymbol = false;
94+
9395
// Flow magic to verify the exports of this file match the original version.
9496
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,7 @@ export const disableDOMTestUtils = false;
9090
export const disableDefaultPropsExceptForClasses = false;
9191
export const enableEarlyReturnForPropDiffing = false;
9292

93+
export const renameElementSymbol = false;
94+
9395
// Flow magic to verify the exports of this file match the original version.
9496
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export const enableSchedulingProfiler: boolean =
6565
export const disableLegacyContext = __EXPERIMENTAL__;
6666
export const enableGetInspectorDataForInstanceInProduction = false;
6767

68+
export const renameElementSymbol = false;
69+
6870
export const enableCache = true;
6971
export const enableLegacyCache = true;
7072
export const enableFetchInstrumentation = false;

0 commit comments

Comments
 (0)