Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a regression related to isReactComponent prototype check #13608

Merged
merged 1 commit into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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