Skip to content

Commit 055193f

Browse files
committed
refactor: chart 무한 스크롤 중복데이터 패칭문제 수정
issues: #33
1 parent de05632 commit 055193f

File tree

1 file changed

+7
-0
lines changed
  • src/features/tradeview/ui/StockChart

1 file changed

+7
-0
lines changed

src/features/tradeview/ui/StockChart/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default function Chart({ ticker = 'BTC', count = 30 }: ChartProps) {
3939
const [isChartReady, setIsChartReady] = useState(false);
4040
const realTimeData = useRealTimeData(ticker);
4141
const pastTimeData = usePastTimeData(ticker, selectedInterval, count);
42+
const prevRequestDate = useRef<Time | null>(null);
4243

4344
const chartOption: DeepPartial<TimeChartOptions> = useMemo(() => {
4445
return {
@@ -89,6 +90,12 @@ export default function Chart({ ticker = 'BTC', count = 30 }: ChartProps) {
8990
if (logicalRange.from < -0.5) {
9091
const firstData = seriesRef.current?.dataByIndex(0) as CandlestickData;
9192
if (!firstData || !firstData.time) return;
93+
if (
94+
prevRequestDate.current &&
95+
prevRequestDate.current <= firstData.time
96+
)
97+
return;
98+
prevRequestDate.current = firstData.time;
9299

93100
const firstDate = timestampToISOString(firstData.time as number);
94101

0 commit comments

Comments
 (0)