Skip to content
refs
12 lines · 470 BRaw
1import { repoLink, type LastChanges } from "@refs/backend/contract";
2import { useEffect } from "react";
3import { useFetcher } from "react-router";
4
5export function useLastChanges(repo: string, ref: string | null, path: readonly string[]): LastChanges | undefined {
6 const fetcher = useFetcher<LastChanges>();
7 const url = ref ? repoLink(repo, "last-commits", ref, path) : null;
8 useEffect(() => {
9 if (url) fetcher.load(url);
10 }, [url]);
11 return fetcher.data;
12}