UNPKG

@antv/s2-react

Version:
18 lines 747 B
import { S2Event } from '@antv/s2'; import React from 'react'; export const useLoading = (s2, loadingFromProps) => { const [loading, setLoading] = React.useState(loadingFromProps !== null && loadingFromProps !== void 0 ? loadingFromProps : false); React.useEffect(() => { s2 === null || s2 === void 0 ? void 0 : s2.on(S2Event.LAYOUT_BEFORE_RENDER, () => { setLoading(true); }); s2 === null || s2 === void 0 ? void 0 : s2.on(S2Event.LAYOUT_AFTER_RENDER, () => { setLoading(false); }); }, [s2]); return { loading: loadingFromProps !== null && loadingFromProps !== void 0 ? loadingFromProps : loading, setLoading, }; }; //# sourceMappingURL=useLoading.js.map