为hook的useSWR添加错误消息

This commit is contained in:
2025-06-19 11:51:23 +08:00
parent 4c9505d476
commit 43e814fbe7
5 changed files with 28 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import { AdminApi } from "@/lib/api";
import { User } from "@/lib/types/user";
import { toast } from "sonner";
import useSWR from "swr";
export function useUser(userId: string) {
@@ -10,6 +11,9 @@ export function useUser(userId: string) {
revalidateOnReconnect: false,
revalidateIfStale: false,
dedupingInterval: 0,
onError: (e) => {
toast.error(`${e.message || e}`)
}
}
)