From e7078a45e725fc052ddc2450a1600dffced7e711 Mon Sep 17 00:00:00 2001 From: Steven Musumeche Date: Fri, 21 Feb 2020 11:36:57 -0600 Subject: [PATCH] [CardMedia] Fix propTypes to allow `component` prop (#19790) --- packages/material-ui/src/CardMedia/CardMedia.js | 6 ++++-- packages/material-ui/src/CardMedia/CardMedia.test.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/material-ui/src/CardMedia/CardMedia.js b/packages/material-ui/src/CardMedia/CardMedia.js index 0e88c028f2b9e7..9c974c6be5ead4 100644 --- a/packages/material-ui/src/CardMedia/CardMedia.js +++ b/packages/material-ui/src/CardMedia/CardMedia.js @@ -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; }), diff --git a/packages/material-ui/src/CardMedia/CardMedia.test.js b/packages/material-ui/src/CardMedia/CardMedia.test.js index 1acc473eff3aaa..8cf27a9ad467f2 100644 --- a/packages/material-ui/src/CardMedia/CardMedia.test.js +++ b/packages/material-ui/src/CardMedia/CardMedia.test.js @@ -91,13 +91,13 @@ describe('', () => { 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(); 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.', ); }); });