Skip to content

Commit

Permalink
refactor: migrate from react-query to @tanstack/react-query
Browse files Browse the repository at this point in the history
  • Loading branch information
xballoy committed Apr 17, 2023
1 parent 8e66be2 commit 870ed70
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions server/apps/frontend/package.json
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@formatjs/intl-numberformat": "8.4.0",
"@tanstack/react-query": "4.0.5",
"@types/node": "18.15.11",
"@types/react": "18.0.35",
"@types/react-dom": "18.0.11",
Expand All @@ -12,8 +13,7 @@
"react": "18.2.0",
"react-bootstrap": "2.7.4",
"react-chartjs-2": "5.2.0",
"react-dom": "18.2.0",
"@tanstack/react-query": "4.0.5"
"react-dom": "18.2.0"
},
"scripts": {
"build": "vite build",
Expand Down
2 changes: 1 addition & 1 deletion server/apps/frontend/src/App.tsx
@@ -1,4 +1,4 @@
import { QueryClient, QueryClientProvider } from 'react-query';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { Seller } from './Seller/Seller';
import './App.css';

Expand Down
18 changes: 9 additions & 9 deletions server/apps/frontend/src/Seller/Seller.hook.ts
@@ -1,5 +1,5 @@
import { useQuery } from '@tanstack/react-query';
import { useEffect, useState } from 'react';
import { useQuery } from 'react-query';

const historyFrequency = 10;
const intervalTime = 5000;
Expand Down Expand Up @@ -44,7 +44,9 @@ export const useSeller = (): {
setSellers((sellersParam: Seller[]) => [...sellersParam, seller]);
};

const { data: dataSellers } = useQuery('getSellers', fetchGetSellers, {
const { data: dataSellers } = useQuery({
queryKey: ['getSellers'],
queryFn: fetchGetSellers,
refetchInterval: intervalTime,
});

Expand All @@ -60,13 +62,11 @@ export const useSeller = (): {
export const useHistory = (): { salesHistory: SalesHistory } => {
const [salesHistory, setSalesHistory] = useState<SalesHistory>();

const { data: dataSalesHistory } = useQuery(
'getSalesHistory',
fetchGetSalesHistory,
{
refetchInterval: intervalTime,
}
);
const { data: dataSalesHistory } = useQuery({
queryKey: ['getSalesHistory'],
queryFn: fetchGetSalesHistory,
refetchInterval: intervalTime,
});

useEffect(() => {
if (dataSalesHistory) {
Expand Down
@@ -1,5 +1,5 @@
import { useMutation } from '@tanstack/react-query';
import React, { FormEvent, RefObject } from 'react';
import { useMutation } from 'react-query';
import { AddSellerType, SellerForm } from '../Seller.hook';

export type ErrorFormType = {
Expand Down

0 comments on commit 870ed70

Please sign in to comment.