mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #4482 from niole/issue4168
Add additional contextual information to invalid-style-prop warning
This commit is contained in:
@@ -261,7 +261,8 @@ 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',
|
||||
getDeclarationErrorAddendum(component)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -721,6 +721,23 @@ describe('ReactDOMComponent', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should report component containing invalid styles', function() {
|
||||
var Animal = React.createClass({
|
||||
render: function() {
|
||||
return <div style={1}></div>;
|
||||
},
|
||||
});
|
||||
|
||||
expect(function() {
|
||||
React.render(<Animal/>, container);
|
||||
}).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. ' +
|
||||
'This DOM node was rendered by `Animal`.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should properly escape text content and attributes values', function() {
|
||||
expect(
|
||||
ReactDOMServer.renderToStaticMarkup(
|
||||
|
||||
Reference in New Issue
Block a user