MCPcopy
hub / github.com/Nutlope/self.so / toast

Function toast

components/ui/use-toast.ts:142–169  ·  view source on GitHub ↗
({ ...props }: Toast)

Source from the content-addressed store, hash-verified

140type Toast = Omit<ToasterToast, 'id'>;
141
142function toast({ ...props }: Toast) {
143 const id = genId();
144
145 const update = (props: ToasterToast) =>
146 dispatch({
147 type: 'UPDATE_TOAST',
148 toast: { ...props, id },
149 });
150 const dismiss = () => dispatch({ type: 'DISMISS_TOAST', toastId: id });
151
152 dispatch({
153 type: 'ADD_TOAST',
154 toast: {
155 ...props,
156 id,
157 open: true,
158 onOpenChange: (open) => {
159 if (!open) dismiss();
160 },
161 },
162 });
163
164 return {
165 id: id,
166 dismiss,
167 update,
168 };
169}
170
171function useToast() {
172 const [state, setState] = React.useState<State>(memoryState);

Callers

nothing calls this directly

Calls 3

genIdFunction · 0.70
dispatchFunction · 0.70
dismissFunction · 0.70

Tested by

no test coverage detected