diff --git a/frontend/package.json b/frontend/package.json index e21fe5b..b309f82 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,7 +5,7 @@ "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.1", "@mui/material": "^5.14.2", - "@tanstack/react-query": "^4.32.6", + "@tanstack/react-query": "^5.0.0", "axios": "^1.4.0", "react": "^18.2.0", "react-dom": "^18.2.0" diff --git a/frontend/src/components/FileDetails/FileDetails.test.tsx b/frontend/src/components/FileDetails/FileDetails.test.tsx index abebbd7..8adf42c 100644 --- a/frontend/src/components/FileDetails/FileDetails.test.tsx +++ b/frontend/src/components/FileDetails/FileDetails.test.tsx @@ -33,7 +33,7 @@ describe("FileDetails", () => { vi.spyOn(fileQueries, "useFileDetails").mockReturnValue({ data: mockItem, isLoading: false, - } as UseQueryResult) + } as UseQueryResult) const user = userEvent.setup() const { getByLabelText, debug, rerender } = render( @@ -63,7 +63,7 @@ describe("FileDetails", () => { vi.spyOn(fileQueries, "useFileDetails").mockReturnValue({ data: mockItem, isLoading: false, - } as UseQueryResult) + } as UseQueryResult) const user = userEvent.setup() const { getByLabelText, debug, rerender } = render( @@ -93,7 +93,7 @@ describe("FileDetails", () => { vi.spyOn(fileQueries, "useFileDetails").mockReturnValue({ data: mockItem, isLoading: false, - } as UseQueryResult) + } as UseQueryResult) const navigateMock = vi.fn().mockImplementation((a: string) => {}) vi.spyOn(locationContextUtils, "useLocationContext").mockReturnValue({ diff --git a/frontend/src/components/LoginView/index.tsx b/frontend/src/components/LoginView/index.tsx index 5e7acaf..9f0838c 100644 --- a/frontend/src/components/LoginView/index.tsx +++ b/frontend/src/components/LoginView/index.tsx @@ -20,7 +20,7 @@ function LoginView() { const [password, setPassword] = React.useState("") const { navigate } = useLocationContext() - const { mutate, isError, isLoading } = useMutation({ + const { mutate, isError, isPending } = useMutation({ mutationFn: async ({ email, password, @@ -97,7 +97,7 @@ function LoginView() { variant="contained" onClick={onLoginClick} aria-label="submit login" - disabled={!isFormValid || isLoading} + disabled={!isFormValid || isPending} > Log in diff --git a/frontend/src/hooks/files.ts b/frontend/src/hooks/files.ts index 6db0cfb..1546cd8 100644 --- a/frontend/src/hooks/files.ts +++ b/frontend/src/hooks/files.ts @@ -4,18 +4,24 @@ import axios from "../axios" import { type FileData } from "../types/files" function useOwnFileList() { - return useQuery(["file-list"], async () => { - const response = await axios.get>("/files/") + return useQuery({ + queryKey: ["file-list"], + queryFn: async () => { + const response = await axios.get>("/files/") - return response.data + return response.data + }, }) } function useFileDetails(fileId: string) { - return useQuery(["file-details", fileId], async () => { - const response = await axios.get(`/files/${fileId}/`) + return useQuery({ + queryKey: ["file-details", fileId], + queryFn: async () => { + const response = await axios.get(`/files/${fileId}/`) - return response.data + return response.data + }, }) } diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 570f97e..b3dd685 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -2120,29 +2120,21 @@ __metadata: languageName: node linkType: hard -"@tanstack/query-core@npm:4.36.1": - version: 4.36.1 - resolution: "@tanstack/query-core@npm:4.36.1" - checksum: 7c648872cd491bcab2aa4c18e0b7ca130c072f05c277a5876977fa3bfa87634bbfde46e9d249236587d78c39866889a02e4e202b478dc6074ff96093732ae56d +"@tanstack/query-core@npm:5.17.0": + version: 5.17.0 + resolution: "@tanstack/query-core@npm:5.17.0" + checksum: bc1fb9c5e78e2c844131e980dbbb9d70f0d8629446af929425a6a4dee25b86186a93deb4653c0246bac750a6214e65572aa1825cb256022ce1d010c748edd735 languageName: node linkType: hard -"@tanstack/react-query@npm:^4.32.6": - version: 4.36.1 - resolution: "@tanstack/react-query@npm:4.36.1" +"@tanstack/react-query@npm:^5.0.0": + version: 5.17.0 + resolution: "@tanstack/react-query@npm:5.17.0" dependencies: - "@tanstack/query-core": "npm:4.36.1" - use-sync-external-store: "npm:^1.2.0" + "@tanstack/query-core": "npm:5.17.0" peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 - react-native: "*" - peerDependenciesMeta: - react-dom: - optional: true - react-native: - optional: true - checksum: 764b860c3ac8d254fc6b07e01054a0f58058644d59626c724b213293fbf1e31c198cbb26e4c32c0d16dcaec0353c0ae19147d9c667675b31f8cea1d64f1ff4ac + react: ^18.0.0 + checksum: 76bf8e8466da4c9cb566e6e83400b8283fb924d9197dcf56154f8f444a365d6d01282a358642ac488964c4de49505886cbc29b53c716dcf5eb6d658a64372d1a languageName: node linkType: hard @@ -4941,7 +4933,7 @@ __metadata: "@emotion/styled": "npm:^11.11.0" "@mui/icons-material": "npm:^5.14.1" "@mui/material": "npm:^5.14.2" - "@tanstack/react-query": "npm:^4.32.6" + "@tanstack/react-query": "npm:^5.0.0" "@testing-library/dom": "npm:^9.3.3" "@testing-library/jest-dom": "npm:^6.1.5" "@testing-library/react": "npm:^14.1.2" @@ -5487,15 +5479,6 @@ __metadata: languageName: node linkType: hard -"use-sync-external-store@npm:^1.2.0": - version: 1.2.0 - resolution: "use-sync-external-store@npm:1.2.0" - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - checksum: a676216affc203876bd47981103f201f28c2731361bb186367e12d287a7566763213a8816910c6eb88265eccd4c230426eb783d64c373c4a180905be8820ed8e - languageName: node - linkType: hard - "util-deprecate@npm:^1.0.1": version: 1.0.2 resolution: "util-deprecate@npm:1.0.2"