MCPcopy
hub / github.com/nraiden/openv0 / useToast

Function useToast

webapps-starters/react/shadcn/src/components/ui/use-toast.tsx:172–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

170}
171
172function useToast() {
173 const [state, setState] = React.useState<State>(memoryState)
174
175 React.useEffect(() => {
176 listeners.push(setState)
177 return () => {
178 const index = listeners.indexOf(setState)
179 if (index > -1) {
180 listeners.splice(index, 1)
181 }
182 }
183 }, [state])
184
185 return {
186 ...state,
187 toast,
188 dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
189 }
190}
191
192export { useToast, toast }

Callers 1

ToasterFunction · 0.90

Calls 1

dispatchFunction · 0.85

Tested by

no test coverage detected