Skip to content

Improve error when you've forgotten to extend React.Component #10103

@jamiebuilds

Description

@jamiebuilds

When you forget to extend React.Component you get the following error:

TypeError: Cannot call a class as a function
    at _classCallCheck (null.js:7:99)
    at Hello (null.js:11:5)
    ...react internals...

[Example]

It would be nice if in dev you could do a check for Component.prototype.render and if it exists, provide a better warning along the lines of:

Warning: Using a class with a render method as a function, did you forget to extend React.Component?

I believe it would happen in ReactCompositeComponent.js.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions