Make IfSlotIsEmpty and IfSloIsNotEmpty accept an array of slot names

This commit is contained in:
Chi Vinh Le
2017-09-29 23:33:12 +07:00
parent f9693c7154
commit 90470b8331
2 changed files with 8 additions and 6 deletions
@@ -23,8 +23,9 @@ class IfSlotIsEmpty extends React.Component {
}
isSlotEmpty(props = this.props) {
const {slot, className: _a, reduxState, component: _b = 'div', children: _c, ...rest} = props;
return this.context.plugins.isSlotEmpty(slot, reduxState, rest);
const {slot, className: _a, reduxState, component: _b = 'div', children: _c, queryData, ...rest} = props;
const slots = Array.isArray(slot) ? slot : [slot];
return slots.every((slot) => this.context.plugins.isSlotEmpty(slot, reduxState, rest, queryData));
}
render() {
@@ -34,7 +35,7 @@ class IfSlotIsEmpty extends React.Component {
}
IfSlotIsEmpty.propTypes = {
slot: PropTypes.string,
slot: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
};
const mapStateToProps = (state) => ({
@@ -23,8 +23,9 @@ class IfSlotIsNotEmpty extends React.Component {
}
isSlotEmpty(props = this.props) {
const {slot, className: _a, reduxState, component: _b = 'div', children: _c, ...rest} = props;
return this.context.plugins.isSlotEmpty(slot, reduxState, rest);
const {slot, className: _a, reduxState, component: _b = 'div', children: _c, queryData, ...rest} = props;
const slots = Array.isArray(slot) ? slot : [slot];
return slots.every((slot) => this.context.plugins.isSlotEmpty(slot, reduxState, rest, queryData));
}
render() {
@@ -34,7 +35,7 @@ class IfSlotIsNotEmpty extends React.Component {
}
IfSlotIsNotEmpty.propTypes = {
slot: PropTypes.string,
slot: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
};
const mapStateToProps = (state) => ({