From 3d4ea24e11994cb0b6cd6de8028241af4cd5d3f0 Mon Sep 17 00:00:00 2001 From: Steven Musumeche Date: Thu, 20 Feb 2020 15:20:04 -0600 Subject: [PATCH 1/3] fix proptypes for CardMedia component --- packages/material-ui/src/CardMedia/CardMedia.d.ts | 1 + packages/material-ui/src/CardMedia/CardMedia.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/material-ui/src/CardMedia/CardMedia.d.ts b/packages/material-ui/src/CardMedia/CardMedia.d.ts index 3ab409785c3448..522ffd081ef5df 100644 --- a/packages/material-ui/src/CardMedia/CardMedia.d.ts +++ b/packages/material-ui/src/CardMedia/CardMedia.d.ts @@ -5,6 +5,7 @@ export interface CardMediaTypeMap { props: P & { image?: string; src?: string; + component?: string | React.Component }; defaultComponent: D; classKey: CardMediaClassKey; diff --git a/packages/material-ui/src/CardMedia/CardMedia.js b/packages/material-ui/src/CardMedia/CardMedia.js index 0e88c028f2b9e7..f062d5357ae3a4 100644 --- a/packages/material-ui/src/CardMedia/CardMedia.js +++ b/packages/material-ui/src/CardMedia/CardMedia.js @@ -66,8 +66,8 @@ 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; }), From d2d5173e03fe81eb5b8f089812d27f194f5396c7 Mon Sep 17 00:00:00 2001 From: Steven Musumeche Date: Thu, 20 Feb 2020 18:40:36 -0600 Subject: [PATCH 2/3] revert typescript changes --- packages/material-ui/src/CardMedia/CardMedia.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/material-ui/src/CardMedia/CardMedia.d.ts b/packages/material-ui/src/CardMedia/CardMedia.d.ts index 522ffd081ef5df..3ab409785c3448 100644 --- a/packages/material-ui/src/CardMedia/CardMedia.d.ts +++ b/packages/material-ui/src/CardMedia/CardMedia.d.ts @@ -5,7 +5,6 @@ export interface CardMediaTypeMap { props: P & { image?: string; src?: string; - component?: string | React.Component }; defaultComponent: D; classKey: CardMediaClassKey; From 7b5a7c6d1c932b36fb0972b4ff3c8e5618c65708 Mon Sep 17 00:00:00 2001 From: Steven Musumeche Date: Thu, 20 Feb 2020 18:40:43 -0600 Subject: [PATCH 3/3] fix tests and formatting --- packages/material-ui/src/CardMedia/CardMedia.js | 4 +++- packages/material-ui/src/CardMedia/CardMedia.test.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/material-ui/src/CardMedia/CardMedia.js b/packages/material-ui/src/CardMedia/CardMedia.js index f062d5357ae3a4..9c974c6be5ead4 100644 --- a/packages/material-ui/src/CardMedia/CardMedia.js +++ b/packages/material-ui/src/CardMedia/CardMedia.js @@ -67,7 +67,9 @@ CardMedia.propTypes = { */ children: chainPropTypes(PropTypes.node, props => { 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 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.', ); }); });