Skip to content

Commit

Permalink
Flag the change
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Apr 21, 2024
1 parent 63e2343 commit ef8ab3a
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/react-dom/src/__tests__/ReactDOMOption-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ describe('ReactDOMOption', () => {
}).rejects.toThrow('Objects are not valid as a React child');
});

// @gate www
it('should support element-ish child', async () => {
// This is similar to <fbt>.
// We don't toString it because you must instead provide a value prop.
const obj = {
$$typeof: Symbol.for('react.transitional.element'),
$$typeof: Symbol.for('react.element'),
type: props => props.content,
ref: null,
key: null,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/refs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,14 @@ describe('ref swapping', () => {
}).rejects.toThrow('Expected ref to be a function');
});

// @gate !enableRefAsProp
// @gate !enableRefAsProp && www
it('undefined ref on manually inlined React element triggers error', async () => {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
await expect(async () => {
await act(() => {
root.render({
$$typeof: Symbol.for('react.transitional.element'),
$$typeof: Symbol.for('react.element'),
type: 'div',
props: {
ref: undefined,
Expand Down
3 changes: 3 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ export const transitionLaneExpirationMs = 5000;

// const __NEXT_MAJOR__ = __EXPERIMENTAL__;

// Renames the internal symbol for elements since they have changed signature/constructor
export const renameElementSymbol = true;

// Removes legacy style context
export const disableLegacyContext = true;

Expand Down
8 changes: 5 additions & 3 deletions packages/shared/ReactSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
* @flow
*/

import {renameElementSymbol} from 'shared/ReactFeatureFlags';

// ATTENTION
// When adding new symbols to this file,
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'

// The Symbol used to tag the ReactElement-like types.
export const REACT_ELEMENT_TYPE: symbol = Symbol.for(
'react.transitional.element',
);
export const REACT_LEGACY_ELEMENT_TYPE: symbol = Symbol.for('react.element');
export const REACT_ELEMENT_TYPE: symbol = renameElementSymbol
? Symbol.for('react.transitional.element')
: REACT_LEGACY_ELEMENT_TYPE;
export const REACT_PORTAL_TYPE: symbol = Symbol.for('react.portal');
export const REACT_FRAGMENT_TYPE: symbol = Symbol.for('react.fragment');
export const REACT_STRICT_MODE_TYPE: symbol = Symbol.for('react.strict_mode');
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export const enableLegacyFBSupport = false;
export const enableFilterEmptyStringAttributesDOM = true;
export const enableGetInspectorDataForInstanceInProduction = true;

export const renameElementSymbol = false;

export const enableRetryLaneExpiration = false;
export const retryLaneExpirationMs = 5000;
export const syncLaneExpirationMs = 250;
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
export const passChildrenWhenCloningPersistedNodes = false;
export const enableEarlyReturnForPropDiffing = false;

export const renameElementSymbol = true;

// Profiling Only
export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = __PROFILE__;
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export const enableServerComponentLogs = true;
export const enableInfiniteRenderLoopDetection = false;
export const enableEarlyReturnForPropDiffing = false;

export const renameElementSymbol = true;

// TODO: This must be in sync with the main ReactFeatureFlags file because
// the Test Renderer's value must be the same as the one used by the
// react package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,7 @@ export const disableDOMTestUtils = false;
export const disableDefaultPropsExceptForClasses = false;
export const enableEarlyReturnForPropDiffing = false;

export const renameElementSymbol = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,7 @@ export const disableDOMTestUtils = false;
export const disableDefaultPropsExceptForClasses = false;
export const enableEarlyReturnForPropDiffing = false;

export const renameElementSymbol = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export const enableSchedulingProfiler: boolean =
export const disableLegacyContext = __EXPERIMENTAL__;
export const enableGetInspectorDataForInstanceInProduction = false;

export const renameElementSymbol = false;

export const enableCache = true;
export const enableLegacyCache = true;
export const enableFetchInstrumentation = false;
Expand Down

0 comments on commit ef8ab3a

Please sign in to comment.