Skip to content
Closed
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
6 changes: 5 additions & 1 deletion src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ function assertValidProps(component, props) {
props.style == null || typeof props.style === 'object',
'The `style` prop expects a mapping from style properties to values, ' +
'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' +
'using JSX.'
'using JSX.%s',
component._currentElement._owner ?
' Check the render method of ' +
component._currentElement._owner.getName() + '.' :
''
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Formatting feels off here. Can we assign owner before the invariant call and use that (can also use a template string instead of concatting the getName(), it'll fit on 1 line when we have owner)

);
}

Expand Down
20 changes: 20 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,26 @@ describe('ReactDOMComponent', function() {
);
});

it('should indicate the owner when validating against invalid styles', function() {
var ReactTestUtils = require('ReactTestUtils');
expect(function() {
var TestComponent = React.createClass({
displayName: 'HelloWorld',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

2 things:

  1. Can probably just depend on the JSX transform adding displayName
  2. Let's move the component definition out of the expect closure and just leave the part that we actually expect to throw in.

render: function render() {
return (
<div style="display: none;" />
);
},
});
ReactTestUtils.renderIntoDocument(<TestComponent />);
}).toThrow(
'Invariant Violation: The `style` prop expects a mapping from style ' +
'properties to values, not a string. For example, ' +
'style={{marginRight: spacing + \'em\'}} when using JSX.' +
' Check the render method of HelloWorld.'
);
});

it('should execute custom event plugin listening behavior', function() {
var SimpleEventPlugin = require('SimpleEventPlugin');

Expand Down