INNER CODE UNIT · TypeScript

reducer

mohammed-bahumaish/prisma-editor · src/hooks/use-toast.ts:74

export const reducer = (state: State, action: Action): State => {
  switch (action.type) {
    case "ADD_TOAST":
      return {
        ...state,
        toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
      };

    case "UPDATE_TOAST":
      return {
        ...state,
        toasts: state.toasts.map((t) =>
          t.id === action.toast.id ? { ...t, ...action.toast } : t
        ),
      };

    case "DISMISS_TOAST":
      const { toastId } = action;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…