[SubCategory] 백그라운드 데이터 페칭 안 되게 플래그 적용, useEffect 의존성 배열에 distpach 추가

This commit is contained in:
hyunwoo93.cha
2024-02-16 22:24:01 +09:00
parent e84bffbab1
commit 7e59ec28fe

View File

@@ -1,28 +1,16 @@
import React, {
useCallback,
useEffect,
useState,
} from 'react';
import React, { useCallback, useEffect, useState } from "react";
import {
useDispatch,
useSelector,
} from 'react-redux';
import { useDispatch, useSelector } from "react-redux";
import VirtualGridList from '@enact/sandstone/VirtualList';
import {
SpotlightContainerDecorator,
} from '@enact/spotlight/SpotlightContainerDecorator';
import Spottable from '@enact/spotlight/Spottable';
import VirtualGridList from "@enact/sandstone/VirtualList";
import { SpotlightContainerDecorator } from "@enact/spotlight/SpotlightContainerDecorator";
import Spottable from "@enact/spotlight/Spottable";
import { getSubCategory } from '../../../actions/mainActions';
import TItemCard from '../../../components/TItemCard/TItemCard';
import {
scaleH,
scaleW,
} from '../../../utils/helperMethods';
import CategoryNav from '../../HomePanel/SubCategory/CategoryNav/CategoryNav';
import css from '../../HomePanel/SubCategory/SubCategory.module.less';
import { getSubCategory } from "../../../actions/mainActions";
import TItemCard from "../../../components/TItemCard/TItemCard";
import { scaleH, scaleW } from "../../../utils/helperMethods";
import CategoryNav from "../../HomePanel/SubCategory/CategoryNav/CategoryNav";
import css from "../../HomePanel/SubCategory/SubCategory.module.less";
const SpottableComponent = Spottable("div");
const Container = SpotlightContainerDecorator(
@@ -62,15 +50,20 @@ const SubCategory = () => {
useEffect(() => {
if (currentLgCatCd) {
dispatch(
getSubCategory({
lgCatCd: currentLgCatCd,
pageSize: "10",
tabType: "CAT00102",
filterType: "CAT00202",
})
getSubCategory(
{
lgCatCd: currentLgCatCd,
pageSize: "10",
tabType: "CAT00102",
filterType: "CAT00202",
},
1,
false
)
);
}
}, [currentLgCatCd]);
}, [currentLgCatCd, dispatch]);
const renderItem = useCallback(
({ index, ...rest }) => {
const itemData = categoryItemInfos[index];