Return immediately if no alerts found
This commit is contained in:
parent
416d41279f
commit
f8e97b8152
|
@ -61,6 +61,11 @@ class StoreAlerts extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { alerts } = this.props;
|
const { alerts } = this.props;
|
||||||
|
|
||||||
|
if ( ! alerts || alerts.length === 0 ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const { currentIndex } = this.state;
|
const { currentIndex } = this.state;
|
||||||
const numberOfAlerts = alerts.length;
|
const numberOfAlerts = alerts.length;
|
||||||
const alert = alerts[ currentIndex ] ? alerts[ currentIndex ] : null;
|
const alert = alerts[ currentIndex ] ? alerts[ currentIndex ] : null;
|
||||||
|
@ -78,7 +83,6 @@ class StoreAlerts extends Component {
|
||||||
) );
|
) );
|
||||||
|
|
||||||
return (
|
return (
|
||||||
numberOfAlerts > 0 && (
|
|
||||||
<Card
|
<Card
|
||||||
title={ [
|
title={ [
|
||||||
alert.icon && <Dashicon key="icon" icon={ alert.icon } />,
|
alert.icon && <Dashicon key="icon" icon={ alert.icon } />,
|
||||||
|
@ -123,7 +127,6 @@ class StoreAlerts extends Component {
|
||||||
/>
|
/>
|
||||||
{ actions && <div className="woocommerce-store-alerts__actions">{ actions }</div> }
|
{ actions && <div className="woocommerce-store-alerts__actions">{ actions }</div> }
|
||||||
</Card>
|
</Card>
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue