Skip to content

Commit 85e7de6

Browse files
committed
1 parent bbb9cb1 commit 85e7de6

31 files changed

+119
-851
lines changed

packages/react-devtools-shared/src/backend/renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export function getInternalReactConstants(version: string): {
220220
HostSingleton: 27, // Same as above
221221
HostText: 6,
222222
IncompleteClassComponent: 17,
223-
IndeterminateComponent: 2,
223+
IndeterminateComponent: 2, // removed in 19.0.0
224224
LazyComponent: 16,
225225
LegacyHiddenComponent: 23,
226226
MemoComponent: 14,

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

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
let React;
1313
let ReactDOM;
1414
let ReactTestUtils;
15-
let PropTypes;
1615

1716
const clone = function (o) {
1817
return JSON.parse(JSON.stringify(o));
@@ -91,7 +90,6 @@ describe('ReactComponentLifeCycle', () => {
9190
React = require('react');
9291
ReactDOM = require('react-dom');
9392
ReactTestUtils = require('react-dom/test-utils');
94-
PropTypes = require('prop-types');
9593
});
9694

9795
it('should not reuse an instance when it has been unmounted', () => {
@@ -983,67 +981,6 @@ describe('ReactComponentLifeCycle', () => {
983981
});
984982
});
985983

986-
if (!require('shared/ReactFeatureFlags').disableModulePatternComponents) {
987-
it('calls effects on module-pattern component', function () {
988-
const log = [];
989-
990-
function Parent() {
991-
return {
992-
render() {
993-
expect(typeof this.props).toBe('object');
994-
log.push('render');
995-
return <Child />;
996-
},
997-
UNSAFE_componentWillMount() {
998-
log.push('will mount');
999-
},
1000-
componentDidMount() {
1001-
log.push('did mount');
1002-
},
1003-
componentDidUpdate() {
1004-
log.push('did update');
1005-
},
1006-
getChildContext() {
1007-
return {x: 2};
1008-
},
1009-
};
1010-
}
1011-
Parent.childContextTypes = {
1012-
x: PropTypes.number,
1013-
};
1014-
function Child(props, context) {
1015-
expect(context.x).toBe(2);
1016-
return <div />;
1017-
}
1018-
Child.contextTypes = {
1019-
x: PropTypes.number,
1020-
};
1021-
1022-
const div = document.createElement('div');
1023-
expect(() =>
1024-
ReactDOM.render(<Parent ref={c => c && log.push('ref')} />, div),
1025-
).toErrorDev(
1026-
'Warning: The <Parent /> component appears to be a function component that returns a class instance. ' +
1027-
'Change Parent to a class that extends React.Component instead. ' +
1028-
"If you can't use a class try assigning the prototype on the function as a workaround. " +
1029-
'`Parent.prototype = React.Component.prototype`. ' +
1030-
"Don't use an arrow function since it cannot be called with `new` by React.",
1031-
);
1032-
ReactDOM.render(<Parent ref={c => c && log.push('ref')} />, div);
1033-
1034-
expect(log).toEqual([
1035-
'will mount',
1036-
'render',
1037-
'did mount',
1038-
'ref',
1039-
1040-
'render',
1041-
'did update',
1042-
'ref',
1043-
]);
1044-
});
1045-
}
1046-
1047984
it('should warn if getDerivedStateFromProps returns undefined', () => {
1048985
class MyComponent extends React.Component {
1049986
state = {};

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

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -111,53 +111,22 @@ describe('ReactCompositeComponent', () => {
111111
};
112112
});
113113

114-
if (require('shared/ReactFeatureFlags').disableModulePatternComponents) {
115-
it('should not support module pattern components', () => {
116-
function Child({test}) {
117-
return {
118-
render() {
119-
return <div>{test}</div>;
120-
},
121-
};
122-
}
123-
124-
const el = document.createElement('div');
125-
expect(() => {
126-
expect(() => ReactDOM.render(<Child test="test" />, el)).toThrow(
127-
'Objects are not valid as a React child (found: object with keys {render}).',
128-
);
129-
}).toErrorDev(
130-
'Warning: The <Child /> component appears to be a function component that returns a class instance. ' +
131-
'Change Child to a class that extends React.Component instead. ' +
132-
"If you can't use a class try assigning the prototype on the function as a workaround. " +
133-
'`Child.prototype = React.Component.prototype`. ' +
134-
"Don't use an arrow function since it cannot be called with `new` by React.",
135-
);
136-
137-
expect(el.textContent).toBe('');
138-
});
139-
} else {
140-
it('should support module pattern components', () => {
141-
function Child({test}) {
142-
return {
143-
render() {
144-
return <div>{test}</div>;
145-
},
146-
};
147-
}
114+
it('should not support module pattern components', () => {
115+
function Child({test}) {
116+
return {
117+
render() {
118+
return <div>{test}</div>;
119+
},
120+
};
121+
}
148122

149-
const el = document.createElement('div');
150-
expect(() => ReactDOM.render(<Child test="test" />, el)).toErrorDev(
151-
'Warning: The <Child /> component appears to be a function component that returns a class instance. ' +
152-
'Change Child to a class that extends React.Component instead. ' +
153-
"If you can't use a class try assigning the prototype on the function as a workaround. " +
154-
'`Child.prototype = React.Component.prototype`. ' +
155-
"Don't use an arrow function since it cannot be called with `new` by React.",
156-
);
123+
const el = document.createElement('div');
124+
expect(() => ReactDOM.render(<Child test="test" />, el)).toThrow(
125+
'Objects are not valid as a React child (found: object with keys {render}).',
126+
);
157127

158-
expect(el.textContent).toBe('test');
159-
});
160-
}
128+
expect(el.textContent).toBe('');
129+
});
161130

162131
it('should support rendering to different child types over time', () => {
163132
const instance = ReactTestUtils.renderIntoDocument(<MorphingComponent />);

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

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -457,60 +457,6 @@ describe('ReactCompositeComponent-state', () => {
457457
]);
458458
});
459459

460-
if (!require('shared/ReactFeatureFlags').disableModulePatternComponents) {
461-
it('should support stateful module pattern components', () => {
462-
function Child() {
463-
return {
464-
state: {
465-
count: 123,
466-
},
467-
render() {
468-
return <div>{`count:${this.state.count}`}</div>;
469-
},
470-
};
471-
}
472-
473-
const el = document.createElement('div');
474-
expect(() => ReactDOM.render(<Child />, el)).toErrorDev(
475-
'Warning: The <Child /> component appears to be a function component that returns a class instance. ' +
476-
'Change Child to a class that extends React.Component instead. ' +
477-
"If you can't use a class try assigning the prototype on the function as a workaround. " +
478-
'`Child.prototype = React.Component.prototype`. ' +
479-
"Don't use an arrow function since it cannot be called with `new` by React.",
480-
);
481-
482-
expect(el.textContent).toBe('count:123');
483-
});
484-
485-
it('should support getDerivedStateFromProps for module pattern components', () => {
486-
function Child() {
487-
return {
488-
state: {
489-
count: 1,
490-
},
491-
render() {
492-
return <div>{`count:${this.state.count}`}</div>;
493-
},
494-
};
495-
}
496-
Child.getDerivedStateFromProps = (props, prevState) => {
497-
return {
498-
count: prevState.count + props.incrementBy,
499-
};
500-
};
501-
502-
const el = document.createElement('div');
503-
ReactDOM.render(<Child incrementBy={0} />, el);
504-
expect(el.textContent).toBe('count:1');
505-
506-
ReactDOM.render(<Child incrementBy={2} />, el);
507-
expect(el.textContent).toBe('count:3');
508-
509-
ReactDOM.render(<Child incrementBy={1} />, el);
510-
expect(el.textContent).toBe('count:4');
511-
});
512-
}
513-
514460
it('should support setState in componentWillUnmount', () => {
515461
let subscription;
516462
class A extends React.Component {

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

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -622,33 +622,20 @@ describe('ReactDOMServerIntegration', () => {
622622
checkFooDiv(await render(<ClassComponent />));
623623
});
624624

625-
if (require('shared/ReactFeatureFlags').disableModulePatternComponents) {
626-
itThrowsWhenRendering(
627-
'factory components',
628-
async render => {
629-
const FactoryComponent = () => {
630-
return {
631-
render: function () {
632-
return <div>foo</div>;
633-
},
634-
};
635-
};
636-
await render(<FactoryComponent />, 1);
637-
},
638-
'Objects are not valid as a React child (found: object with keys {render})',
639-
);
640-
} else {
641-
itRenders('factory components', async render => {
625+
itThrowsWhenRendering(
626+
'factory components',
627+
async render => {
642628
const FactoryComponent = () => {
643629
return {
644630
render: function () {
645631
return <div>foo</div>;
646632
},
647633
};
648634
};
649-
checkFooDiv(await render(<FactoryComponent />, 1));
650-
});
651-
}
635+
await render(<FactoryComponent />, 1);
636+
},
637+
'Objects are not valid as a React child (found: object with keys {render})',
638+
);
652639
});
653640

654641
describe('component hierarchies', function () {

packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -799,46 +799,6 @@ describe('ReactErrorBoundaries', () => {
799799
expect(container.firstChild.textContent).toBe('Caught an error: Hello.');
800800
});
801801

802-
// @gate !disableModulePatternComponents
803-
// @gate !disableLegacyContext
804-
it('renders an error state if module-style context provider throws in componentWillMount', () => {
805-
function BrokenComponentWillMountWithContext() {
806-
return {
807-
getChildContext() {
808-
return {foo: 42};
809-
},
810-
render() {
811-
return <div>{this.props.children}</div>;
812-
},
813-
UNSAFE_componentWillMount() {
814-
throw new Error('Hello');
815-
},
816-
};
817-
}
818-
BrokenComponentWillMountWithContext.childContextTypes = {
819-
foo: PropTypes.number,
820-
};
821-
822-
const container = document.createElement('div');
823-
expect(() =>
824-
ReactDOM.render(
825-
<ErrorBoundary>
826-
<BrokenComponentWillMountWithContext />
827-
</ErrorBoundary>,
828-
container,
829-
),
830-
).toErrorDev(
831-
'Warning: The <BrokenComponentWillMountWithContext /> component appears to be a function component that ' +
832-
'returns a class instance. ' +
833-
'Change BrokenComponentWillMountWithContext to a class that extends React.Component instead. ' +
834-
"If you can't use a class try assigning the prototype on the function as a workaround. " +
835-
'`BrokenComponentWillMountWithContext.prototype = React.Component.prototype`. ' +
836-
"Don't use an arrow function since it cannot be called with `new` by React.",
837-
);
838-
839-
expect(container.firstChild.textContent).toBe('Caught an error: Hello.');
840-
});
841-
842802
it('mounts the error message if mounting fails', () => {
843803
function renderError(error) {
844804
return <ErrorMessage message={error.message} />;

packages/react-dom/src/__tests__/ReactLegacyErrorBoundaries-test.internal.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -825,45 +825,6 @@ describe('ReactLegacyErrorBoundaries', () => {
825825
expect(container.firstChild.textContent).toBe('Caught an error: Hello.');
826826
});
827827

828-
if (!require('shared/ReactFeatureFlags').disableModulePatternComponents) {
829-
it('renders an error state if module-style context provider throws in componentWillMount', () => {
830-
function BrokenComponentWillMountWithContext() {
831-
return {
832-
getChildContext() {
833-
return {foo: 42};
834-
},
835-
render() {
836-
return <div>{this.props.children}</div>;
837-
},
838-
UNSAFE_componentWillMount() {
839-
throw new Error('Hello');
840-
},
841-
};
842-
}
843-
BrokenComponentWillMountWithContext.childContextTypes = {
844-
foo: PropTypes.number,
845-
};
846-
847-
const container = document.createElement('div');
848-
expect(() =>
849-
ReactDOM.render(
850-
<ErrorBoundary>
851-
<BrokenComponentWillMountWithContext />
852-
</ErrorBoundary>,
853-
container,
854-
),
855-
).toErrorDev(
856-
'Warning: The <BrokenComponentWillMountWithContext /> component appears to be a function component that ' +
857-
'returns a class instance. ' +
858-
'Change BrokenComponentWillMountWithContext to a class that extends React.Component instead. ' +
859-
"If you can't use a class try assigning the prototype on the function as a workaround. " +
860-
'`BrokenComponentWillMountWithContext.prototype = React.Component.prototype`. ' +
861-
"Don't use an arrow function since it cannot be called with `new` by React.",
862-
);
863-
expect(container.firstChild.textContent).toBe('Caught an error: Hello.');
864-
});
865-
}
866-
867828
it('mounts the error message if mounting fails', () => {
868829
function renderError(error) {
869830
return <ErrorMessage message={error.message} />;

0 commit comments

Comments
 (0)