diff --git a/package.json b/package.json index 30755e2..8ba8ab8 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "react-dom": "^18.3.1", "react-hook-form": "^7.54.1", "react-router-dom": "^7.1.0", + "react-spinners": "^0.15.0", "react-toastify": "^11.0.2", "zustand": "^5.0.2" }, diff --git a/src/components/Loading.tsx b/src/components/Loading.tsx new file mode 100644 index 0000000..455b7ee --- /dev/null +++ b/src/components/Loading.tsx @@ -0,0 +1,15 @@ +import { FadeLoader } from 'react-spinners'; + +const Loading = () => { + return ( +
+
+

로딩 중..

+
+ +
+
+ ); +}; + +export default Loading; diff --git a/src/main.tsx b/src/main.tsx index 01dad95..8e4b553 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,16 +1,19 @@ -import { StrictMode } from 'react'; +import { StrictMode, Suspense } from 'react'; import { createRoot } from 'react-dom/client'; import { RouterProvider } from 'react-router-dom'; import { router } from './router'; import './index.css'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import Loading from './components/Loading'; const queryClient = new QueryClient(); createRoot(document.getElementById('root')!).render( - + }> + + , ); diff --git a/src/pages/detail/detail.tsx b/src/pages/detail/detail.tsx index 98d2974..59f1918 100644 --- a/src/pages/detail/detail.tsx +++ b/src/pages/detail/detail.tsx @@ -20,6 +20,7 @@ import Counter from '../../components/Counter'; import { toast } from 'react-toastify'; import CheckBuyList from '../../components/CheckOrder/CheckBuyList'; import { viewPaymentStore } from '../../store/detailStore'; +import Loading from '../../components/Loading'; const Detail = () => { const axios = axiosInstance; @@ -40,7 +41,8 @@ const Detail = () => { const postNum: number = Number(_id); const { data, refetch } = useQuery({ queryKey: ['products', _id], - queryFn: () => axios.get(`/products/${postNum}`), + queryFn: () => setTimeout(() => axios.get(`/products/${postNum}`), 1000), + // queryFn: () => axios.get(`/products/${postNum}`), select: (res) => { if (res.data.item.seller_id == loginId) setIsEditor(true); return res.data; @@ -151,7 +153,7 @@ const Detail = () => { }; if (!data) { - return
로딩중...
; + return ; } const productType: string = data.item.extra.type;