@antv/s2-react
Version:
use S2 with react
23 lines • 973 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLoading = void 0;
const tslib_1 = require("tslib");
const s2_1 = require("@antv/s2");
const react_1 = tslib_1.__importDefault(require("react"));
const useLoading = (s2, loadingFromProps) => {
const [loading, setLoading] = react_1.default.useState(loadingFromProps !== null && loadingFromProps !== void 0 ? loadingFromProps : false);
react_1.default.useEffect(() => {
s2 === null || s2 === void 0 ? void 0 : s2.on(s2_1.S2Event.LAYOUT_BEFORE_RENDER, () => {
setLoading(true);
});
s2 === null || s2 === void 0 ? void 0 : s2.on(s2_1.S2Event.LAYOUT_AFTER_RENDER, () => {
setLoading(false);
});
}, [s2]);
return {
loading: loadingFromProps !== null && loadingFromProps !== void 0 ? loadingFromProps : loading,
setLoading,
};
};
exports.useLoading = useLoading;
//# sourceMappingURL=useLoading.js.map
;