[gcalendar] Upgrade react-query:3 to @tanstack/react-query:4

Signed-off-by: Tomasz Szuba <tszuba@box.com>
This commit is contained in:
Tomasz Szuba
2022-08-17 15:53:56 +02:00
parent b6c8637fdc
commit a69ac5b63a
6 changed files with 39 additions and 86 deletions
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import React from 'react';
import { QueryClient, QueryClientProvider } from 'react-query';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { CalendarCard } from './CalendarCard';
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useQuery } from 'react-query';
import { useQuery } from '@tanstack/react-query';
import { errorApiRef, useApi } from '@backstage/core-plugin-api';
@@ -15,12 +15,11 @@
*/
import { compact, unescape } from 'lodash';
import { useMemo } from 'react';
import { useQueries } from 'react-query';
import { useQueries } from '@tanstack/react-query';
import { useApi } from '@backstage/core-plugin-api';
import { gcalendarApiRef } from '../api';
import { GCalendar, GCalendarEvent } from '../api';
import { gcalendarApiRef, GCalendar, GCalendarEvent } from '../api';
type Options = {
selectedCalendars?: string[];
@@ -41,8 +40,8 @@ export const useEventsQuery = ({
timeZone,
}: Options) => {
const calendarApi = useApi(gcalendarApiRef);
const eventQueries = useQueries(
selectedCalendars
const eventQueries = useQueries({
queries: selectedCalendars
.filter(id => calendars.find(c => c.id === id))
.map(calendarId => {
const calendar = calendars.find(c => c.id === calendarId);
@@ -53,6 +52,7 @@ export const useEventsQuery = ({
initialData: [],
refetchInterval: 60000,
refetchIntervalInBackground: true,
queryFn: async (): Promise<GCalendarEvent[]> => {
const data = await calendarApi.getEvents(calendarId, {
calendarId,
@@ -82,7 +82,7 @@ export const useEventsQuery = ({
},
};
}),
);
});
const events = useMemo(
() => compact(eventQueries.map(({ data }) => data).flat()),