Whether a loading placeholder should show: not until the load has run for delay, and, once shown, for at least minVisible. A load that ends within delay shows nothing, and a placeholder that shows stays for minVisible.
import { useLoadingVisible } from "@/lib/ouro/use-loading-visible";Example
const visible = useLoadingVisible(query.isPending);
return visible ? <Skeleton shape="row" count={6} /> : query.data ? <List data={query.data} /> : null;Usage
Use it to time a placeholder of your own; Skeleton carries no timing of its own, so an app that skips the hook pays no bytes.
Use instead when
- Use
Button'sloadinginstead for an action in progress.
Parameters
loading- Type:
boolean options- Type:
LoadingVisibleOptions {}
Returns
boolean
Types
LoadingVisibleOptions
Options for useLoadingVisible.
interface LoadingVisibleOptions {
/** How long a load runs before its placeholder shows, in milliseconds. @default 200 */
delay?: number | undefined;
/** How long a placeholder that has shown stays, in milliseconds. @default 500 */
minVisible?: number | undefined;
}
