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.
export default function( props ) {
let Icon = function() {
return null;
};
let Icon;
switch ( props.icon ) {
case 'arrow-down-alt2':
Icon = ArrowDownIcon;
@ -24,6 +22,11 @@ export default function( props ) {
Icon = DismissIcon;
break;
}
if ( ! Icon ) {
return null;
}
return cloneElement( Icon, {
size: props.size || 20,
className: props.className,