use-toast.ts — ui Source File
Architecture documentation for use-toast.ts, a typescript file in the ui codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR bba373ff_472d_b9de_12be_a7a606cb2977["use-toast.ts"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] bba373ff_472d_b9de_12be_a7a606cb2977 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 24b98a33_2ada_5229_61ae_aeb1a46ab80e["toast"] bba373ff_472d_b9de_12be_a7a606cb2977 --> 24b98a33_2ada_5229_61ae_aeb1a46ab80e style bba373ff_472d_b9de_12be_a7a606cb2977 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
// Inspired by react-hot-toast library
import * as React from "react"
import type {
ToastActionElement,
ToastProps,
} from "@/registry/new-york/ui/toast"
const TOAST_LIMIT = 1
const TOAST_REMOVE_DELAY = 1000000
type ToasterToast = ToastProps & {
id: string
title?: React.ReactNode
description?: React.ReactNode
action?: ToastActionElement
}
const actionTypes = {
ADD_TOAST: "ADD_TOAST",
UPDATE_TOAST: "UPDATE_TOAST",
DISMISS_TOAST: "DISMISS_TOAST",
REMOVE_TOAST: "REMOVE_TOAST",
} as const
let count = 0
function genId() {
count = (count + 1) % Number.MAX_SAFE_INTEGER
return count.toString()
}
type ActionType = typeof actionTypes
type Action =
| {
type: ActionType["ADD_TOAST"]
toast: ToasterToast
}
| {
type: ActionType["UPDATE_TOAST"]
toast: Partial<ToasterToast>
}
| {
type: ActionType["DISMISS_TOAST"]
toastId?: ToasterToast["id"]
}
| {
type: ActionType["REMOVE_TOAST"]
toastId?: ToasterToast["id"]
}
interface State {
toasts: ToasterToast[]
}
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()
// ... (135 more lines)
Domain
Subdomains
Dependencies
- react
- toast
Source
Frequently Asked Questions
What does use-toast.ts do?
use-toast.ts is a source file in the ui codebase, written in typescript. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in use-toast.ts?
use-toast.ts defines 7 function(s): addToRemoveQueue, dispatch, genId, reducer, state, toast, useToast.
What does use-toast.ts depend on?
use-toast.ts imports 2 module(s): react, toast.
Where is use-toast.ts in the architecture?
use-toast.ts is located at deprecated/www/registry/new-york/hooks/use-toast.ts (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/registry/new-york/hooks).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free