@vlsergey/react-bootstrap-pagetable
Version:
Complex solution to work with pageable data, including sorting, filtering, actions, changing displayed columns, etc.
15 lines (14 loc) • 577 B
JavaScript
import { __assign, __read } from "tslib";
import React, { useEffect, useRef, useState } from 'react';
export default function DivHideIfEmpty(props) {
var ref = useRef(null);
var _a = __read(useState(false), 2), hide = _a[0], setHide = _a[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.createElement("div", __assign({}, props, { ref: ref }));
}