Dashicon module replacement: prevent cloning a non-element (https://github.com/woocommerce/woocommerce-blocks/pull/2804)

This commit is contained in:
Albert Juhé Lluveras 2020-07-03 10:51:37 +02:00 committed by GitHub
parent c49a7af270
commit 2013c5e0f5
1 changed files with 6 additions and 3 deletions

View File

@ -13,9 +13,7 @@ import { cloneElement } from '@wordpress/element';
// the Webpack NormalModuleReplacementPlugin plugin. // the Webpack NormalModuleReplacementPlugin plugin.
export default function( props ) { export default function( props ) {
let Icon = function() { let Icon;
return null;
};
switch ( props.icon ) { switch ( props.icon ) {
case 'arrow-down-alt2': case 'arrow-down-alt2':
Icon = ArrowDownIcon; Icon = ArrowDownIcon;
@ -24,6 +22,11 @@ export default function( props ) {
Icon = DismissIcon; Icon = DismissIcon;
break; break;
} }
if ( ! Icon ) {
return null;
}
return cloneElement( Icon, { return cloneElement( Icon, {
size: props.size || 20, size: props.size || 20,
className: props.className, className: props.className,