useReportList 상호 의존 문제 해결
This commit is contained in:
parent
21caac8c63
commit
aad1a7b447
|
|
@ -1,4 +1,4 @@
|
|||
import { useState, useEffect, useCallback } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { ReportMaster, GetReportsParams } from "@/types/report";
|
||||
import { reportApi } from "@/lib/api/reportApi";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
|
|
@ -12,7 +12,7 @@ export function useReportList() {
|
|||
const [searchText, setSearchText] = useState("");
|
||||
const { toast } = useToast();
|
||||
|
||||
const fetchReports = useCallback(async () => {
|
||||
const fetchReports = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const params: GetReportsParams = {
|
||||
|
|
@ -31,6 +31,7 @@ export function useReportList() {
|
|||
setTotal(response.data.total);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("리포트 목록 조회 에러:", error);
|
||||
toast({
|
||||
title: "오류",
|
||||
description: error.message || "리포트 목록을 불러오는데 실패했습니다.",
|
||||
|
|
@ -39,16 +40,17 @@ export function useReportList() {
|
|||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, [page, limit, searchText, toast]);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchReports();
|
||||
}, [fetchReports]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [page, searchText]);
|
||||
|
||||
const handleSearch = useCallback((text: string) => {
|
||||
const handleSearch = (text: string) => {
|
||||
setSearchText(text);
|
||||
setPage(1);
|
||||
}, []);
|
||||
};
|
||||
|
||||
return {
|
||||
reports,
|
||||
|
|
|
|||
Loading…
Reference in New Issue