improvements in react-query

- fetch to useFetch hook
- refetch every 10s
- sync browser tabs with experimental broadcastQueryClient
This commit is contained in:
cv
2021-04-24 15:05:18 +02:00
parent e8bca40653
commit 3f8c6f1192
6 changed files with 32 additions and 15 deletions
+4 -3
View File
@@ -1,9 +1,10 @@
import { useEffect, useState } from 'react';
import { useQuery } from 'react-query';
import { eventsNamespace, fetchAllEvents } from '../../app/api/eventsApi';
import { fetchEvent, eventNamespace } from '../../app/api/eventApi';
import { useSocket } from '../../app/context/socketContext';
import { stringFromMillis } from '../../common/dateConfig';
import { useFetch } from '../../app/hooks/useFetch';
const withSocket = (Component) => {
const WrappedComponent = (props) => {
@@ -11,12 +12,12 @@ const withSocket = (Component) => {
data: eventsData,
status: eventsDataStatus,
isError: eventsDataIsError,
} = useQuery(eventsNamespace, fetchAllEvents);
} = useFetch(eventsNamespace, fetchAllEvents);
const {
data: genData,
status: genDataStatus,
isError: genDataIsError,
} = useQuery(eventNamespace, fetchEvent);
} = useFetch(eventNamespace, fetchEvent);
const [publicEvents, setPublicEvents] = useState([]);
const [backstageEvents, setBackstageEvents] = useState([]);