Skip to content

Commit e12d0dc

Browse files
[CardMedia] Fix propTypes to allow component prop (#19790)
1 parent 264684b commit e12d0dc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/material-ui/src/CardMedia/CardMedia.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ CardMedia.propTypes = {
6666
* The content of the component.
6767
*/
6868
children: chainPropTypes(PropTypes.node, props => {
69-
if (!props.children && !props.image && !props.src) {
70-
return new Error('Material-UI: either `children`, `image` or `src` prop must be specified.');
69+
if (!props.children && !props.image && !props.src && !props.component) {
70+
return new Error(
71+
'Material-UI: either `children`, `image`, `src` or `component` prop must be specified.',
72+
);
7173
}
7274
return null;
7375
}),

packages/material-ui/src/CardMedia/CardMedia.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ describe('<CardMedia />', () => {
9191
PropTypes.resetWarningCache();
9292
});
9393

94-
it('warns when neither `children`, nor `image`, nor `src` are provided', () => {
94+
it('warns when neither `children`, nor `image`, nor `src`, nor `component` are provided', () => {
9595
mount(<CardMedia />);
9696

9797
assert.strictEqual(consoleErrorMock.callCount(), 1);
9898
assert.include(
9999
consoleErrorMock.args()[0][0],
100-
'Material-UI: either `children`, `image` or `src` prop must be specified.',
100+
'Material-UI: either `children`, `image`, `src` or `component` prop must be specified.',
101101
);
102102
});
103103
});

0 commit comments

Comments
 (0)