MCPcopy Index your code
hub / github.com/adobe/react-spectrum / useToastQueue

Function useToastQueue

packages/react-stately/src/toast/useToastState.ts:72–84  ·  view source on GitHub ↗
(queue: ToastQueue<T>)

Source from the content-addressed store, hash-verified

70 * Subscribes to a provided toast queue and provides methods to update it.
71 */
72export function useToastQueue<T>(queue: ToastQueue<T>): ToastState<T> {
73 let subscribe = useCallback(fn => queue.subscribe(fn), [queue]);
74 let getSnapshot = useCallback(() => queue.visibleToasts, [queue]);
75 let visibleToasts = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
76
77 return {
78 visibleToasts,
79 add: (content, options) => queue.add(content, options),
80 close: key => queue.close(key),
81 pauseAll: () => queue.pauseAll(),
82 resumeAll: () => queue.resumeAll()
83 };
84}
85
86/**
87 * A ToastQueue manages the order of toasts.

Callers 3

Toast.tsxFile · 0.90
ToastContainerFunction · 0.90
useToastStateFunction · 0.85

Calls 6

useSyncExternalStoreFunction · 0.90
addMethod · 0.65
closeMethod · 0.65
pauseAllMethod · 0.65
resumeAllMethod · 0.65
subscribeMethod · 0.45

Tested by

no test coverage detected