SearchBaseForm ref 연결 완료.

This commit is contained in:
truthwing
2025-04-22 17:57:45 +09:00
parent 675a3583b7
commit 75aeadd69d
@@ -15,6 +15,7 @@ type SearchBaseType = {
queryClick:(returnType:ReturnType) => void;
excelClick:(returnType:ReturnType) => void;
btnClass:string;
ref:React.RefObject<HTMLDivElement>;
}
export type ReturnType = {
partValue: string;
@@ -40,7 +41,8 @@ function SearchBaseForm ({
selectEnvPartData,
btnClass,
queryClick,
excelClick
excelClick,
ref
}: SearchBaseType) {
const [partValue, setPartValue] = useState<string>("0");
const [sidoValue, setSidoValue] = useState<string>("0");
@@ -74,9 +76,7 @@ function SearchBaseForm ({
setResetTrigger(false);
}
}, [resetTrigger]);
const excelDownload = useCallback(() => {
console.log("엑셀다운로드 클릭");
console.log(partValue, sidoValue, sigunValue, regionValue, untitWaterShedValue, middleRegionValue, envPartValue, envPartSidoValue, envPartSigunValue);
const excelDownload = () => {
excelClick({
partValue: partValue,
sidoValue: sidoValue,
@@ -88,20 +88,21 @@ function SearchBaseForm ({
envPartSidoValue: envPartSidoValue,
envPartSigunValue: envPartSigunValue,
})
};
useEffect(() => {
if (ref && ref.current) {
const customRef = ref.current as HTMLDivElement & ReturnType;
customRef.partValue = partValue;
customRef.sidoValue = sidoValue;
customRef.sigunValue = sigunValue;
customRef.regionValue = regionValue;
customRef.unitWaterShedValue = untitWaterShedValue;
customRef.middleRegionValue = middleRegionValue;
customRef.envPartValue = envPartValue;
customRef.envPartSidoValue = envPartSidoValue;
customRef.envPartSigunValue = envPartSigunValue;
}
}, [partValue, sidoValue, sigunValue, regionValue, untitWaterShedValue, middleRegionValue, envPartValue, envPartSidoValue, envPartSigunValue]);
// useEffect(() => {
// if (ref && ref.current) {
// ref.current.partValue = partValue;
// ref.current.sidoValue = sidoValue;
// ref.current.sigunValue = sigunValue;
// ref.current.regionValue = regionValue;
// ref.current.unitWaterShedValue = untitWaterShedValue;
// ref.current.middleRegionValue = middleRegionValue;
// ref.current.envPartValue = envPartValue;
// ref.current.envPartSidoValue = envPartSidoValue;
// ref.current.envPartSigunValue = envPartSigunValue;
// }
// }, [partValue, sidoValue, sigunValue, regionValue, untitWaterShedValue, middleRegionValue, envPartValue, envPartSidoValue, envPartSigunValue]);
return (
<div className="flex card card-border !mt-6">
<SearchFormLeft isShowPart={true}