Skip to content

Commit

Permalink
refactor: change useQueryClient
Browse files Browse the repository at this point in the history
  • Loading branch information
qwer0114 authored and qwer0114 committed Nov 28, 2024
1 parent 84b47d4 commit e25d14c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/client/src/pages/home/components/Coin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Heart from '@asset/heart.svg?react';
import { useNavigate } from 'react-router-dom';
import colorClasses from '@/constants/priceColor';
import useRecentlyMarketStore from '@/store/recentlyViewed';
import { QueryClient } from '@tanstack/react-query';
import { useQueryClient } from '@tanstack/react-query';
import { useToggleMyInterest } from '@/hooks/interest/useToggleMyInterest';

type CoinProps = {
Expand All @@ -17,15 +17,16 @@ type CoinProps = {

function Coin({ formatters, market, sseData, isInterest }: CoinProps) {
const navigate = useNavigate();
const queryClient = new QueryClient();
const queryClient = useQueryClient();
const { addRecentlyViewedMarket } = useRecentlyMarketStore();
const { toggleInterest } = useToggleMyInterest();
const handleClick = () => {
addRecentlyViewedMarket(market.market);
navigate(`/trade/KRW-${market.market.split('-')[1]}`);
queryClient.invalidateQueries({ queryKey: ['recentlyMarketList'] });
};
const handleToggle = async () => {
const handleToggle = async (e: React.MouseEvent) => {
e.stopPropagation();
toggleInterest.mutateAsync(market.market);
};
const change: Change = sseData[market.market]?.change;
Expand Down

0 comments on commit e25d14c

Please sign in to comment.