Skip to content

Commit

Permalink
www: make disableLegacyMode dynamic flag (#29774)
Browse files Browse the repository at this point in the history
This makes the flag dynamic for Meta and turns it on for the www test
renderer.
  • Loading branch information
kassens authored Jun 7, 2024
1 parent 827cbea commit 142b2a8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ describe('ReactComponentLifeCycle', () => {
expect(instance.updater.isMounted(instance)).toBe(false);
});

// @gate www && !disableLegacyMode
// @gate www && classic
it('warns if legacy findDOMNode is used inside render', async () => {
class Component extends React.Component {
state = {isMounted: false};
Expand Down
16 changes: 8 additions & 8 deletions packages/react-dom/src/__tests__/findDOMNodeFB-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const ReactDOM = require('react-dom');
const StrictMode = React.StrictMode;

describe('findDOMNode', () => {
// @gate www && !disableLegacyMode
// @gate www && classic
it('findDOMNode should return null if passed null', () => {
expect(ReactDOM.findDOMNode(null)).toBe(null);
});

// @gate www && !disableLegacyMode
// @gate www && classic && !disableLegacyMode
it('findDOMNode should find dom element', () => {
class MyNode extends React.Component {
render() {
Expand All @@ -39,7 +39,7 @@ describe('findDOMNode', () => {
expect(mySameDiv).toBe(myDiv);
});

// @gate www && !disableLegacyMode
// @gate www && classic && !disableLegacyMode
it('findDOMNode should find dom element after an update from null', () => {
function Bar({flag}) {
if (flag) {
Expand All @@ -66,14 +66,14 @@ describe('findDOMNode', () => {
expect(b.tagName).toBe('SPAN');
});

// @gate www && !disableLegacyMode
// @gate www && classic
it('findDOMNode should reject random objects', () => {
expect(function () {
ReactDOM.findDOMNode({foo: 'bar'});
}).toThrowError('Argument appears to not be a ReactComponent. Keys: foo');
});

// @gate www && !disableLegacyMode
// @gate www && classic && !disableLegacyMode
it('findDOMNode should reject unmounted objects with render func', () => {
class Foo extends React.Component {
render() {
Expand All @@ -90,7 +90,7 @@ describe('findDOMNode', () => {
);
});

// @gate www && !disableLegacyMode
// @gate www && classic && !disableLegacyMode
it('findDOMNode should not throw an error when called within a component that is not mounted', () => {
class Bar extends React.Component {
UNSAFE_componentWillMount() {
Expand All @@ -107,7 +107,7 @@ describe('findDOMNode', () => {
}).not.toThrow();
});

// @gate www && !disableLegacyMode
// @gate www && classic && !disableLegacyMode
it('findDOMNode should warn if used to find a host component inside StrictMode', () => {
let parent = undefined;
let child = undefined;
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('findDOMNode', () => {
expect(match).toBe(child);
});

// @gate www && !disableLegacyMode
// @gate www && classic && !disableLegacyMode
it('findDOMNode should warn if passed a component that is inside StrictMode', () => {
let parent = undefined;
let child = undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const disableStringRefs = false;
export const enableFastJSX = false;

export const enableReactTestRendererWarning = false;
export const disableLegacyMode = false;
export const disableLegacyMode = true;

export const disableDefaultPropsExceptForClasses = false;
export const enableAddPropertiesFastPath = false;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.www-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const retryLaneExpirationMs = 5000;
export const syncLaneExpirationMs = 250;
export const transitionLaneExpirationMs = 5000;
export const enableAddPropertiesFastPath = __VARIANT__;
export const disableLegacyMode = __VARIANT__;

// Enable this flag to help with concurrent mode debugging.
// It logs information to the console about React scheduling, rendering, and commit phases.
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ export const useModernStrictMode = true;
// because JSX is an extremely hot path.
export const disableStringRefs = false;

export const disableLegacyMode = __EXPERIMENTAL__;
export const disableLegacyMode: boolean =
__EXPERIMENTAL__ || dynamicFeatureFlags.disableLegacyMode;

export const enableOwnerStacks = false;
export const enableShallowPropDiffing = false;
Expand Down

0 comments on commit 142b2a8

Please sign in to comment.