www: make disableLegacyMode dynamic flag (#29774)

This makes the flag dynamic for Meta and turns it on for the www test
renderer.
This commit is contained in:
Jan Kassens
2024-06-07 07:36:10 -04:00
committed by GitHub
parent 827cbea417
commit 142b2a8230
5 changed files with 13 additions and 11 deletions
@@ -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};
+8 -8
View File
@@ -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() {
@@ -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) {
@@ -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() {
@@ -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() {
@@ -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;
@@ -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;
@@ -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;
@@ -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.
@@ -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;