[onSalePanel] CategoryNav, 함수 추가 및 props 변경
Detail Notes : 1. OnSalePanel.jsx, handleCategoryNavClick 삭제 2. CategoryNav.jsx, props 변경, handleCategoryNavClick 추가
This commit is contained in:
@@ -21,22 +21,33 @@ const Container = SpotlightContainerDecorator(
|
||||
export default function CategoryNav({
|
||||
categoryInfos,
|
||||
currentCategoryCode,
|
||||
onCategoryNavClick,
|
||||
setCurrentCategoryCode,
|
||||
...rest
|
||||
}) {
|
||||
const handleCategoryNavClick = useCallback(
|
||||
(categoryCode) => {
|
||||
if (currentCategoryCode === categoryCode) {
|
||||
return;
|
||||
}
|
||||
|
||||
setCurrentCategoryCode(categoryCode);
|
||||
},
|
||||
[currentCategoryCode]
|
||||
);
|
||||
|
||||
const renderItem = useCallback(
|
||||
({ index, ...rest }) => {
|
||||
return (
|
||||
<CategoryNavItem
|
||||
categoryInfos={categoryInfos}
|
||||
currentCategoryCode={currentCategoryCode}
|
||||
onCategoryNavClick={onCategoryNavClick}
|
||||
onCategoryNavClick={handleCategoryNavClick}
|
||||
index={index}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[categoryInfos, currentCategoryCode, onCategoryNavClick]
|
||||
[categoryInfos, currentCategoryCode, handleCategoryNavClick]
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
@@ -22,17 +22,6 @@ export default function OnSalePanel() {
|
||||
const [currentCategoryCode, setCurrentCategoryCode] = useState();
|
||||
const [targetId, setTargetId] = useState();
|
||||
|
||||
const handleCategoryNavClick = useCallback(
|
||||
(categoryCode) => {
|
||||
if (currentCategoryCode === categoryCode) {
|
||||
return;
|
||||
}
|
||||
|
||||
setCurrentCategoryCode(categoryCode);
|
||||
},
|
||||
[currentCategoryCode]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (categoryInfos && !currentCategoryCode) {
|
||||
const initialLgCatCd = categoryInfos[0].lgCatCd;
|
||||
@@ -60,7 +49,7 @@ export default function OnSalePanel() {
|
||||
<CategoryNav
|
||||
categoryInfos={categoryInfos}
|
||||
currentCategoryCode={currentCategoryCode}
|
||||
onCategoryNavClick={handleCategoryNavClick}
|
||||
setCurrentCategoryCode={setCurrentCategoryCode}
|
||||
/>
|
||||
<TBody className={css.tBody}>
|
||||
{saleInfos &&
|
||||
|
||||
Reference in New Issue
Block a user