ILoadingProps
@spartanfx/react / ILoadingProps
Interface: ILoadingProps
Props for the Loading component.
Remarks
- When
loadingistrue, a global Notiflix loading overlay is shown. - If multiple Loading instances are mounted at the same time, a reference
counter ensures the overlay remains visible until all instances unmount or set
loadingtofalse. - The
messageis shown inside the overlay; it updates reactively whileloadingistrue.
Examples
// Minimal usage: show a loader while data is fetched
export function Page() {
const [busy, setBusy] = React.useState(false);
React.useEffect(() => {
setBusy(true);
fetch('/api/data').finally(() => setBusy(false));
}, []);
return (
<>
<Loading loading={busy} />
<main>...</main>
</>
);
}
// Multiple loaders: overlay stays visible until ALL are done
export function ComplexFlow() {
const [stepA, setA] = React.useState(false);
const [stepB, setB] = React.useState(false);
React.useEffect(() => {
setA(true); setB(true);
Promise.all([doA(), doB()]).finally(() => { setA(false); setB(false); });
}, []);
return (
<>
<Loading loading={stepA} message="Processing step A…" />
<Loading loading={stepB} message="Processing step B…" />
<section>...</section>
</>
);
}