Fix a regression related to isReactComponent prototype check (#13608)

This commit is contained in:
Dan Abramov
2018-09-10 17:54:45 +01:00
committed by GitHub
parent 03ab1efeb4
commit 4a40d76245
2 changed files with 15 additions and 6 deletions
@@ -1762,4 +1762,18 @@ describe('ReactCompositeComponent', () => {
{withoutStack: true},
);
});
// Regression test for accidental breaking change
// https://github.com/facebook/react/issues/13580
it('should support classes shadowing isReactComponent', () => {
class Shadow extends React.Component {
isReactComponent() {}
render() {
return <div />;
}
}
const container = document.createElement('div');
ReactDOM.render(<Shadow />, container);
expect(container.firstChild.tagName).toBe('DIV');
});
});
+1 -6
View File
@@ -284,12 +284,7 @@ const createFiber = function(
function shouldConstruct(Component: Function) {
const prototype = Component.prototype;
return (
typeof prototype === 'object' &&
prototype !== null &&
typeof prototype.isReactComponent === 'object' &&
prototype.isReactComponent !== null
);
return !!(prototype && prototype.isReactComponent);
}
export function resolveLazyComponentTag(