Fix a regression related to isReactComponent prototype check (#13608)
Dan Abramov committed
Sep 10, 2018 at 17:54 UTC
4a40d7624575d030e2d2aa98b24000e59a9e4f02
2 files changed
+15
-6
packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
+14
@@ -1762,4 +1762,18 @@ describe('ReactCompositeComponent', () => {
1762
{withoutStack: true},
1763
);
1764
});
1765
+
1766
+ // Regression test for accidental breaking change
1767
+ // https://github.com/facebook/react/issues/13580
1768
+ it('should support classes shadowing isReactComponent', () => {
1769
+ class Shadow extends React.Component {
1770
+ isReactComponent() {}
1771
+ render() {
1772
+ return <div />;
1773
+ }
1774
+ }
1775
+ const container = document.createElement('div');
1776
+ ReactDOM.render(<Shadow />, container);
1777
+ expect(container.firstChild.tagName).toBe('DIV');
1778
+ });
1779
});
packages/react-reconciler/src/ReactFiber.js
+1
-6
@@ -284,12 +284,7 @@ const createFiber = function(
284
285
function shouldConstruct(Component: Function) {
286
const prototype = Component.prototype;
287
- return (
288
- typeof prototype === 'object' &&
289
- prototype !== null &&
290
- typeof prototype.isReactComponent === 'object' &&
291
- prototype.isReactComponent !== null
292
- );
287
+ return !!(prototype && prototype.isReactComponent);
288
}
289
290
export function resolveLazyComponentTag(