API reference > @kontsedal/olas-react > useSuspendOnHidden
useSuspendOnHidden() function
Auto-suspend a controller when document.visibilityState === 'hidden', and resume on visible. See spec §20.10.
The effect undoes itself on cleanup: if it is the reason the controller is suspended, it resumes before it goes. Unmounting a hidden tab's subtree — or swapping the controller argument while hidden — would otherwise leave that controller suspended with nothing left listening for thevisibilitychange that was supposed to wake it.
It shares its bookkeeping with <SuspendOnUnmount>, so it resumes only a controller nothing else holds suspended. A controller whose last wrapper unmounted while the tab was hidden stays suspended when the tab shows, and when this hook's own component unmounts.
Signature:
export declare function useSuspendOnHidden(controller: SuspendableController): void;Parameters
Parameter | Type | Description |
|---|---|---|
controller |
Returns:
void