Skip to content
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
5 changes: 3 additions & 2 deletions src/classic/element/ReactElementValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function checkPropTypes(componentName, propTypes, props, location) {
// same error.
loggedTypeFailures[error.message] = true;

var addendum = getDeclarationErrorAddendum(this);
var addendum = getDeclarationErrorAddendum();
warning(false, 'Failed propType: %s%s', error.message, addendum);
}
}
Expand Down Expand Up @@ -402,7 +402,8 @@ var ReactElementValidator = {
type != null,
'React.createElement: type should not be null or undefined. It should ' +
'be a string (for DOM elements) or a ReactClass (for composite ' +
'components).'
'components).%s',
getDeclarationErrorAddendum()
);

var element = ReactElement.createElement.apply(this, arguments);
Expand Down
21 changes: 21 additions & 0 deletions src/classic/element/__tests__/ReactElementValidator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,27 @@ describe('ReactElementValidator', function() {
expect(console.warn.calls.length).toBe(2);
});

it('includes the owner name when passing null or undefined', function() {
spyOn(console, 'warn');
var ParentComp = React.createClass({
render: function() {
return React.createElement(null);
}
});
expect(function() {
ReactTestUtils.renderIntoDocument(React.createElement(ParentComp));
}).toThrow();
expect(console.warn.calls.length).toBe(2);
expect(console.warn.calls[0].args[0]).toBe(
'Warning: React.createElement: type should not be null or undefined. ' +
'It should be a string (for DOM elements) or a ReactClass (for ' +
'composite components). Check the render method of `ParentComp`.'
);
expect(console.warn.calls[1].args[0]).toBe(
'Warning: Only functions or strings can be mounted as React components.'
);
});

it('should check default prop values', function() {
spyOn(console, 'warn');

Expand Down