Skip to content

Commit 5698e23

Browse files
gaearonSimek
authored andcommitted
Fix a regression related to isReactComponent prototype check (facebook#13608)
1 parent 0aa787f commit 5698e23

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,4 +1762,18 @@ describe('ReactCompositeComponent', () => {
17621762
{withoutStack: true},
17631763
);
17641764
});
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+
});
17651779
});

packages/react-reconciler/src/ReactFiber.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,7 @@ const createFiber = function(
284284

285285
function shouldConstruct(Component: Function) {
286286
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);
293288
}
294289

295290
export function resolveLazyComponentTag(

0 commit comments

Comments
 (0)