Skip to content

Commit

Permalink
[CardMedia] Fix propTypes to allow component prop (mui#19790)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmusumeche authored and EsoterikStare committed Mar 30, 2020
1 parent 628abe9 commit e7078a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/material-ui/src/CardMedia/CardMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ CardMedia.propTypes = {
* The content of the component.
*/
children: chainPropTypes(PropTypes.node, props => {
if (!props.children && !props.image && !props.src) {
return new Error('Material-UI: either `children`, `image` or `src` prop must be specified.');
if (!props.children && !props.image && !props.src && !props.component) {
return new Error(
'Material-UI: either `children`, `image`, `src` or `component` prop must be specified.',
);
}
return null;
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/CardMedia/CardMedia.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ describe('<CardMedia />', () => {
PropTypes.resetWarningCache();
});

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

assert.strictEqual(consoleErrorMock.callCount(), 1);
assert.include(
consoleErrorMock.args()[0][0],
'Material-UI: either `children`, `image` or `src` prop must be specified.',
'Material-UI: either `children`, `image`, `src` or `component` prop must be specified.',
);
});
});
Expand Down

0 comments on commit e7078a4

Please sign in to comment.