Skip to content

Commit d05c6aa

Browse files
update packages (including react-query v5)
1 parent 2bcbb39 commit d05c6aa

File tree

9 files changed

+582
-612
lines changed

9 files changed

+582
-612
lines changed

package-lock.json

Lines changed: 519 additions & 554 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,36 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"@azure/core-auth": "^1.5.0",
14-
"@azure/msal-browser": "^3.1.0",
15-
"@azure/msal-react": "^2.0.3",
13+
"@azure/core-auth": "^1.7.2",
14+
"@azure/msal-browser": "^3.13.0",
15+
"@azure/msal-react": "^2.0.15",
1616
"@developer-platform/entities": "^0.4.29",
17-
"@emotion/react": "^11.11.1",
18-
"@emotion/styled": "^11.11.0",
17+
"@emotion/react": "^11.11.4",
18+
"@emotion/styled": "^11.11.5",
1919
"@microsoft/microsoft-graph-client": "^3.0.7",
20-
"@mui/icons-material": "^5.14.9",
21-
"@mui/material": "^5.14.10",
22-
"@rjsf/core": "5.16.1",
23-
"@rjsf/mui": "5.16.1",
24-
"@rjsf/utils": "5.16.1",
25-
"@rjsf/validator-ajv8": "5.16.1",
26-
"@tanstack/react-query": "^4.35.3",
27-
"@tanstack/react-query-devtools": "^4.35.3",
20+
"@mui/icons-material": "^5.15.15",
21+
"@mui/material": "^5.15.15",
22+
"@rjsf/core": "5.18.2",
23+
"@rjsf/mui": "5.18.2",
24+
"@rjsf/utils": "5.18.2",
25+
"@rjsf/validator-ajv8": "5.18.2",
26+
"@tanstack/react-query": "^5.32.0",
27+
"@tanstack/react-query-devtools": "^5.32.0",
2828
"react": "^18.2.0",
2929
"react-dom": "^18.2.0",
30-
"react-router-dom": "^6.16.0",
30+
"react-router-dom": "^6.23.0",
3131
"vite-plugin-svgr": "^4.2.0"
3232
},
3333
"devDependencies": {
34-
"@types/react": "^18.2.56",
35-
"@types/react-dom": "^18.2.19",
36-
"@typescript-eslint/eslint-plugin": "^7.0.2",
37-
"@typescript-eslint/parser": "^7.0.2",
34+
"@types/react": "^18.2.79",
35+
"@types/react-dom": "^18.2.25",
36+
"@typescript-eslint/eslint-plugin": "^7.7.1",
37+
"@typescript-eslint/parser": "^7.7.1",
3838
"@vitejs/plugin-react": "^4.2.1",
3939
"eslint": "^8.56.0",
4040
"eslint-plugin-react-hooks": "^4.6.0",
41-
"eslint-plugin-react-refresh": "^0.4.5",
42-
"typescript": "^5.2.2",
43-
"vite": "^5.1.4"
41+
"eslint-plugin-react-refresh": "^0.4.6",
42+
"typescript": "^5.4.5",
43+
"vite": "^5.1.10"
4444
}
4545
}

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const App: React.FC = () => (
2727
<Route path='/*' element={<RootView />} />
2828
</Routes>
2929
</BrowserRouter>
30-
<ReactQueryDevtools initialIsOpen={false} position='bottom-right' />
30+
<ReactQueryDevtools initialIsOpen={false} />
3131
</QueryClientProvider>
3232
);
3333

src/components/CreateForm.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ export const CreateForm: React.FC<ICreateFormProps> = () => {
2222

2323
const { data: templates, isLoading } = useEntities('template');
2424

25+
// const { data: tt } = useEntity({
26+
// kind: 'template',
27+
// provider: provider ?? '',
28+
// namespace: namespace ?? '',
29+
// name: name ?? '',
30+
// });
31+
2532
const create = useTemplateCreate();
2633

2734
const [template, setTemplate] = useState<Template>();

src/hooks/useEntities.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export const useEntities = (kind: string) => {
1010
const isAuthenticated = useIsAuthenticated();
1111
const queryClient = useQueryClient();
1212

13-
return useQuery(
14-
['entities', kind.toLowerCase()],
15-
async () => {
13+
return useQuery({
14+
queryKey: ['entities', kind.toLowerCase()],
15+
queryFn: async () => {
1616
console.log(`Fetching ${kind} entities`);
1717

1818
const { entities, providerAuth } = await getEntities(kind);
@@ -46,11 +46,9 @@ export const useEntities = (kind: string) => {
4646

4747
return entities;
4848
},
49-
{
50-
refetchOnMount: false,
51-
refetchOnWindowFocus: false,
52-
staleTime: 1000 * 60 * 2, // 2 minutes
53-
enabled: isAuthenticated,
54-
}
55-
);
49+
refetchOnMount: false,
50+
refetchOnWindowFocus: false,
51+
staleTime: 1000 * 60 * 2, // 2 minutes
52+
enabled: isAuthenticated,
53+
});
5654
};

src/hooks/useEntity.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import { getEntity } from '../API';
99
export const useEntity = (ref: EntityRef) => {
1010
const isAuthenticated = useIsAuthenticated();
1111

12-
return useQuery(
13-
[
12+
return useQuery({
13+
queryKey: [
1414
'entities',
1515
ref.kind.toLowerCase(),
1616
ref.provider.toLowerCase(),
1717
ref.namespace?.toLowerCase() ?? 'default',
1818
ref.name.toLowerCase(),
1919
],
20-
async () => {
20+
queryFn: async () => {
2121
console.log(`Fetching ${ref.kind} entity ${ref.kind}:${ref.provider}/${ref.namespace ?? 'default'}/${ref.name}`);
2222

2323
const entity = await getEntity(ref);
@@ -48,11 +48,9 @@ export const useEntity = (ref: EntityRef) => {
4848

4949
return entity;
5050
},
51-
{
52-
refetchOnMount: false,
53-
refetchOnWindowFocus: false,
54-
staleTime: 1000 * 60 * 2, // 2 minutes
55-
enabled: isAuthenticated,
56-
}
57-
);
51+
refetchOnMount: false,
52+
refetchOnWindowFocus: false,
53+
staleTime: 1000 * 60 * 2, // 2 minutes
54+
enabled: isAuthenticated,
55+
});
5856
};

src/hooks/useGraphUser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { getMe } from '../MSGraph';
88
export const useGraphUser = () => {
99
const isAuthenticated = useIsAuthenticated();
1010

11-
return useQuery(['graphUser', 'me'], async () => await getMe(), {
11+
return useQuery({
12+
queryKey: ['graphUser', 'me'],
13+
queryFn: async () => await getMe(),
1214
refetchOnMount: false,
1315
refetchOnWindowFocus: false,
1416
staleTime: 1000 * 60 * 5, // 5 minutes

src/hooks/useProviderAuth.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { useQuery } from '@tanstack/react-query';
88
export const useProviderAuth = () => {
99
const isAuthenticated = useIsAuthenticated();
1010

11-
return useQuery(['providers', 'auth'], () => [] as ProviderAuth[], {
11+
return useQuery({
12+
queryKey: ['providers', 'auth'],
13+
queryFn: () => [] as ProviderAuth[],
1214
refetchOnMount: false,
1315
refetchOnWindowFocus: false,
1416
staleTime: Infinity,

src/hooks/useTemplateCreate.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@ export const useTemplateCreate = () => {
1515

1616
const queryClient = useQueryClient();
1717

18-
return useMutation(
19-
async (payload: CreatePayload) => {
18+
return useMutation({
19+
mutationFn: async (payload: CreatePayload) => {
2020
const operation = await create(payload.ref, payload.input);
2121
return operation;
2222
},
23-
{
24-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
25-
onSuccess: async (_data: Operation, _variables: CreatePayload, _context: unknown) => {
26-
const sleepSeconds = 3;
27-
navigate(`/new`);
28-
console.log(`Invalidating entities after ${sleepSeconds} seconds...`);
29-
await sleep(sleepSeconds * 1000);
30-
console.log(`Invalidating entities`);
31-
queryClient.invalidateQueries(['entities'], { type: 'all' });
32-
},
33-
}
34-
).mutateAsync;
23+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
24+
onSuccess: async (_data: Operation, _variables: CreatePayload, _context: unknown) => {
25+
const sleepSeconds = 3;
26+
navigate(`/new`);
27+
console.log(`Invalidating entities after ${sleepSeconds} seconds...`);
28+
await sleep(sleepSeconds * 1000);
29+
console.log(`Invalidating entities`);
30+
queryClient.invalidateQueries({ queryKey: ['entities'], type: 'all' });
31+
},
32+
}).mutateAsync;
3533
};

0 commit comments

Comments
 (0)