소스 정보
- 저장소
- emanueleielo/deepagents-open-lovable
- 최근 소스 활동
- 2026년 1월 8일 10:15
- 감지된 SKILL.md 언어
- 영어
- 스타
- 109
- 포크
- 25
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/emanueleielo/deepagents-open-lovable --skill data-fetching명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | data-fetching |
| description | Data fetching with TanStack Query, loading states, and error handling |
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
interface User {
id: string;
name: string;
email: string;
}
// API functions
async function fetchUser(userId: string): Promise<User> {
const res = await fetch(`/api/users/${userId}`);
if (!res.ok) throw new Error("Failed to fetch user");
return res.json();
}
async function updateUser(user: Partial<User> & { id: string }): Promise<User> {
const res = await fetch(`/api/users/${user.id}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(user),
});
if (!res.ok) throw new Error("Failed to update user");
return res.json();
}
// Component
function UserProfile({ userId }: { userId: string }) {
const { data: user, isLoading, error } = useQuery({
queryKey: ["user", userId],
queryFn: () => fetchUser(userId),
});
if (isLoading) return <UserSkeleton />;
if (error) return <ErrorMessage error={error} />;
return (
<div>
<h1>{user.name}</h1>
<p>{user.email}</p>
</div>
);
}
function UserEditor({ userId }: { userId: string }) {
const queryClient = useQueryClient();
const mutation = useMutation({
mutationFn: updateUser,
// Optimistic update
onMutate: async (newUser) => {
// Cancel outgoing refetches
await queryClient.cancelQueries({ queryKey: ["user", userId] });
// Snapshot previous value
const previousUser = queryClient.getQueryData<User>(["user", userId]);
// Optimistically update
queryClient.setQueryData<User>(["user", userId], (old) => ({
...old!,
...newUser,
}));
return { previousUser };
},
// Rollback on error
onError: (err, newUser, context) => {
queryClient.setQueryData(["user", userId], context?.previousUser);
},
// Always refetch after error or success
onSettled: () => {
queryClient.invalidateQueries({ queryKey: ["user", userId] });
},
});
return (
<form = => {
e.preventDefault();
mutation.mutate({ id: userId, name: "New Name" });
}}>
{mutation.isPending ? "Saving..." : "Save"}
{mutation.isError && Error: {mutation.error.message}}
);
}
import { useInfiniteQuery } from "@tanstack/react-query";
interface Page {
items: Item[];
nextCursor?: string;
}
function InfiniteList() {
const {
data,
fetchNextPage,
hasNextPage,
isFetchingNextPage,
} = useInfiniteQuery({
queryKey: ["items"],
queryFn: ({ pageParam }) => fetchItems(pageParam),
initialPageParam: undefined as string | undefined,
getNextPageParam: (lastPage) => lastPage.nextCursor,
});
const items = data?.pages.flatMap((page) => page.items) ?? [];
return (
<div>
{items.map((item) => (
<ItemCard key={item.id} item={item} />
))}
{hasNextPage && (
<button
onClick={() => fetchNextPage()}
disabled={isFetchingNextPage}
>
{isFetchingNextPage ? "Loading..." : "Load More"}
</>
)}
);
}
function UserPosts({ userId }: { userId: string }) {
// First query
const { data: user } = useQuery({
queryKey: ["user", userId],
queryFn: () => fetchUser(userId),
});
// Dependent query - only runs when user is available
const { data: posts } = useQuery({
queryKey: ["posts", user?.id],
queryFn: () => fetchUserPosts(user!.id),
enabled: !!user, // Only run when user exists
});
return (
<div>
<h1>{user?.name}'s Posts</h1>
{posts?.map((post) => <PostCard key={post.id} post={post} />)}
</div>
);
}
function UserList() {
const queryClient = useQueryClient();
return (
<ul>
{users.map((user) => (
<li
key={user.id}
// Prefetch on hover
onMouseEnter={() => {
queryClient.prefetchQuery({
queryKey: ["user", user.id],
queryFn: () => fetchUser(user.id),
staleTime: 5 * 60 * 1000, // 5 minutes
});
}}
>
<Link href={`/users/${user.id}`}>{user.name}</Link>
</li>
))}
</ul>
);
}
// Skeleton component
function UserSkeleton() {
return (
<div className="animate-pulse">
<div className="h-8 w-48 bg-muted rounded" />
<div className="h-4 w-32 bg-muted rounded mt-2" />
</div>
);
}
// Error component with retry
function ErrorMessage({ error, retry }: { error: Error; retry?: () => void }) {
return (
<div className="rounded-md bg-red-50 p-4">
<div className="flex">
<AlertCircle className="h-5 w-5 text-red-400" />
<div className="ml-3">
<h3 className="text-sm font-medium text-red-800">Error</h3>
<p className="text-sm text-red-700 mt-1">{error.message}</p>
{retry && (
<
=
=
>
Try again
)}
);
}
() {
{ data, isLoading, error, refetch } = ({
: [, userId],
: (userId),
: ,
});
(isLoading) ;
(error) ;
;
}
// app/users/[id]/page.tsx
async function UserPage({ params }: { params: { id: string } }) {
const user = await fetchUser(params.id);
return (
<div>
<h1>{user.name}</h1>
{/* Client component for interactive features */}
<Suspense fallback={<PostsSkeleton />}>
<UserPosts userId={user.id} />
</Suspense>
</div>
);
}
// Revalidation
export const revalidate = 60; // Revalidate every 60 seconds
// Hierarchical keys for proper invalidation
const queryKeys = {
all: ["users"] as const,
lists: () => [...queryKeys.all, "list"] as const,
list: (filters: Filters) => [...queryKeys.lists(), filters] as const,
details: () => [...queryKeys.all, "detail"] as const,
detail: (id: string) => [...queryKeys.details(), id] as const,
};
// Usage
useQuery({ queryKey: queryKeys.detail(userId), ... });
// Invalidate all user queries
queryClient.invalidateQueries({ queryKey: queryKeys.all });
// Invalidate only lists
queryClient.invalidateQueries({ queryKey: queryKeys.lists() });