MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / toast

Function toast

website/src/hooks/use-toast.ts:137–164  ·  view source on GitHub ↗
({ ...props }: Toast)

Source from the content-addressed store, hash-verified

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

Callers 5

handleGenerateBundleFunction · 0.85
pollBundleStatusFunction · 0.85
handleNewsletterSubmitFunction · 0.85
copyToClipboardFunction · 0.85
handleCopyFunction · 0.85

Calls 3

genIdFunction · 0.85
dispatchFunction · 0.85
dismissFunction · 0.85

Tested by

no test coverage detected