UNPKG

@wener/console

Version:

Base console UI toolkit

22 lines (21 loc) 707 B
import { useState } from "react"; import { useAsyncEffect } from "@wener/reaction"; import { LoadingIndicator } from "../../console/index.js"; import { getSiteStore } from "./SiteStore.js"; export const SiteLoader = ({ children, getSiteConf }) => { const [init, setInit] = useState(!getSiteConf); useAsyncEffect(async () => { if (!getSiteConf) return; const cfg = await getSiteConf(); getSiteStore().getState().load(cfg); setTimeout(() => { setInit(true); }, 0); }, []); if (!init) { return /*#__PURE__*/ React.createElement(LoadingIndicator, null); } return children; }; //# sourceMappingURL=SiteLoader.js.map