MCPcopy Create free account
hub / github.com/adobe/react-spectrum / close

Method close

packages/react-stately/src/toast/useToastState.ts:135–143  ·  view source on GitHub ↗

* Closes a toast.

(key: string)

Source from the content-addressed store, hash-verified

133 * Closes a toast.
134 */
135 close(key: string): void {
136 let index = this.queue.findIndex(t => t.key === key);
137 if (index >= 0) {
138 this.queue[index].onClose?.();
139 this.queue.splice(index, 1);
140 }
141
142 this.updateVisibleToasts('remove');
143 }
144
145 private updateVisibleToasts(action: ToastAction) {
146 this.visibleToasts = this.queue.slice(0, this.maxVisibleToasts);

Callers 1

addMethod · 0.95

Calls 1

updateVisibleToastsMethod · 0.95

Tested by

no test coverage detected