useProgress
useProgress returns a number that climbs from initialValue to 100 on a timer. Use it for simulated progress
while a task with no real percentage runs. It has no pause, reset or completion control.Hooks
Signature
const progress = useProgress(initialValue?, increment?, time?);
Name | Type | Description |
|---|---|---|
initialValue | number | Starting value (0–100). Default 0. |
increment | 1 | 5 | 10 | 15 | … | 45 | 50 | Step size. Default 1. |
time | number | null | Milliseconds a full 0 → 100 run takes. Default 3000. null or 0 freezes the value. |
returns | number | The current value, clamped at 100. |
Scrolls sideways inside the table. The page does not.
Example
import { ProgressBar } from '@apollion-dsi/core/elements/progress-bar';
import { useProgress } from '@apollion-dsi/core/hooks';
function Preparing() {
const progress = useProgress(0, 5, 2000);
return <ProgressBar progress={progress} aria-label="Preparing export" />;
}Pitfalls
- The value reaches
100on time, not when your task ends. Unmount it or switch to the real value when the task completes. - Each step lasts
time / 100 × incrementms, so a non-zeroinitialValuefinishes sooner thantime. - Changing
initialValueafter mount has no effect.