MCPcopy
hub / github.com/Nutlope/logocreator / toast

Function toast

hooks/use-toast.ts:143–170  ·  view source on GitHub ↗
({ ...props }: Toast)

Source from the content-addressed store, hash-verified

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

Callers 1

generateLogoFunction · 0.90

Calls 3

genIdFunction · 0.85
dispatchFunction · 0.85
dismissFunction · 0.85

Tested by

no test coverage detected