Skip to content

Commit

Permalink
Fix a regression related to isReactComponent prototype check (#13608)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Sep 10, 2018
1 parent 03ab1ef commit 4a40d76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
14 changes: 14 additions & 0 deletions packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
7 changes: 1 addition & 6 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4a40d76

Please sign in to comment.