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

Constructor error message #11395

Merged
merged 9 commits into from
Nov 1, 2017
Merged
Changes from 1 commit
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
31 changes: 17 additions & 14 deletions packages/react-reconciler/src/ReactFiberClassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,24 @@ module.exports = function(
const name = getComponentName(workInProgress);
const renderPresent = instance.render;

if (type.prototype && type.prototype.render !== undefined) {
warning(
renderPresent,
'%s(...): No `render` method found on the returned component ' +
'instance: is the `constructor` defined well?',
name,
);
} else {
warning(
renderPresent,
'%s(...): No `render` method found on the returned component ' +
'instance: you may have forgotten to define `render`.',
name,
);
if (!renderPresent) {
if (type.prototype && type.prototype.render !== undefined) {
warning(
false,
'%s(...): No `render` method found on the returned component ' +
'instance: is the `constructor` defined well?',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be explicit: "did you accidentally return an object from the constructor"

name,
);
} else {
warning(
false,
'%s(...): No `render` method found on the returned component ' +
'instance: you may have forgotten to define `render`.',
name,
);
}
}

const noGetInitialStateOnES6 =
!instance.getInitialState ||
instance.getInitialState.isReactClassApproved ||
Expand Down