Skip to content

Commit 582bc93

Browse files
committed
Merge pull request facebook#2583 from spicyj/style-example
Add example for how to use `style` properly
2 parents c6ed9df + 1c54431 commit 582bc93

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/browser/ui/ReactDOMComponent.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ function assertValidProps(props) {
6969
invariant(
7070
props.style == null || typeof props.style === 'object',
7171
'The `style` prop expects a mapping from style properties to values, ' +
72-
'not a string.'
72+
'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' +
73+
'using JSX.'
7374
);
7475
}
7576

src/browser/ui/__tests__/ReactDOMComponent-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ describe('ReactDOMComponent', function() {
353353
mountComponent({ style: 'display: none' });
354354
}).toThrow(
355355
'Invariant Violation: The `style` prop expects a mapping from style ' +
356-
'properties to values, not a string.'
356+
'properties to values, not a string. For example, ' +
357+
'style={{marginRight: spacing + \'em\'}} when using JSX.'
357358
);
358359
});
359360
});
@@ -398,7 +399,8 @@ describe('ReactDOMComponent', function() {
398399
React.render(<div style={1}></div>, container);
399400
}).toThrow(
400401
'Invariant Violation: The `style` prop expects a mapping from style ' +
401-
'properties to values, not a string.'
402+
'properties to values, not a string. For example, ' +
403+
'style={{marginRight: spacing + \'em\'}} when using JSX.'
402404
);
403405
});
404406
});

0 commit comments

Comments
 (0)