Skip to content

Commit

Permalink
[Add] React-Query devtools 설치
Browse files Browse the repository at this point in the history
- 데이터 fetching 최적화 위해 React-Query Devtools 설치
- Devtools 사용위해 @tanstack/react-query로 라이브러리 교체 (기존에 react-query 라이브러리 사용)

Issues #122
  • Loading branch information
novice1993 committed Sep 28, 2023
1 parent 2f0fd71 commit 3e6aded
Show file tree
Hide file tree
Showing 23 changed files with 245 additions and 225 deletions.
203 changes: 108 additions & 95 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"@hyunbinseo/holidays-kr": "^2.2024.4",
"@react-oauth/google": "^0.11.1",
"@reduxjs/toolkit": "^1.9.5",
"@tanstack/react-query": "^4.35.3",
"@tanstack/react-query-devtools": "^4.35.3",
"axios": "^1.5.0",
"boxicons": "^2.1.4",
"echarts": "^5.4.3",
Expand All @@ -21,7 +23,6 @@
"gapi-script": "^1.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-query": "^3.39.3",
"react-redux": "^8.1.2",
"react-router-dom": "^6.15.0",
"react-spinners": "^0.13.8",
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/MarketComponents/MarketKospiChart.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as echarts from "echarts";
import { styled } from "styled-components";
import { useState, useEffect } from "react";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import axios from "axios";

const MarketkospiChart = () => {
const [kospiData, setKospiData] = useState([]);

const { data, isLoading, error } = useQuery("kospi", getKospiData, {});
const { data, isLoading, error } = useQuery(["kospi"], getKospiData, {});

useEffect(() => {
if (data) {
Expand Down
18 changes: 9 additions & 9 deletions client/src/hooks/stars/useDeletestars.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { useMutation } from 'react-query';
import { useMutation } from "@tanstack/react-query";

// DELETE 요청을 수행하는 함수
const deleteStarData = async (companyId: number) => {
const accessToken = sessionStorage.getItem('accessToken');
const accessToken = sessionStorage.getItem("accessToken");
const response = await fetch(`http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/stars/?companyId=${companyId}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Authorization': `${accessToken}`
},
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: `${accessToken}`,
},
});

if (!response.ok) {
throw new Error('Failed to delete star data.');
throw new Error("Failed to delete star data.");
}

// DELETE 요청은 본문을 반환하지 않는 경우가 많으므로 json 변환을 생략
return true; // 삭제가 성공적으로 완료됨을 나타냅니다.
return true; // 삭제가 성공적으로 완료됨을 나타냅니다.
};

const useDeleteStar = () => {
Expand Down
Loading

0 comments on commit 3e6aded

Please sign in to comment.