ToastProvider
Returned from
initToast
A component for rendering the toast-list.
caution
ToastProvider is an alternative to useToasts, not a supplement.
Props
renderToasts: Takes a component with the following props:toasts:Array<T & { id: string }>The list of current toastsonRemoveToast:(toastId: string) => voidRemoves the given toast from the listcancelToastTimeout:(toastId: string) => voidCancels whatever timeout the given toast has for removing itself.restartToastTimeout:(toastId: string, removeAfterMs?: number) => voidRestarts whatever timeout the given toast has for removing itself.
removeToastsAfterMs?:number | undefinedSpecifies the default timeout for toasts to be auto-removed. (undefined = no auto removal).onToastAdded?:(toast: T) => voidA function called whenever a new toast is fired.portal?:HTMLElementIf given, determines where to portal the toast-list to.
Returns
The component returns a ReactElement if no portal is specified, otherwise a ReactPortal.