@vlsergey/react-bootstrap-pagetable
Version:
Complex solution to work with pageable data, including sorting, filtering, actions, changing displayed columns, etc.
18 lines (17 loc) • 710 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
function DivHideIfEmpty(props) {
var ref = react_1.useRef(null);
var _a = tslib_1.__read(react_1.useState(false), 2), hide = _a[0], setHide = _a[1];
react_1.useEffect(function () {
setHide(!!ref.current &&
(!ref.current.innerHTML || /^(<(div|span)>)*(<\/(div|span)>)*$/.test(ref.current.innerHTML)));
}, [setHide, props]);
if (hide) {
return null;
}
return react_1.default.createElement("div", tslib_1.__assign({}, props, { ref: ref }));
}
exports.default = DivHideIfEmpty;
;