Skip to content

Commit d9a1eac

Browse files
committed
fix(skeleton): do not use router hook inside useAuthenticatedFetch
1 parent 8efe126 commit d9a1eac

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

skeleton/src/hooks/useAuthenticatedFetch.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { useAuth0 } from "@auth0/auth0-react";
2-
import { useLocation } from "@tanstack/react-router";
32
import { useCallback } from "react";
43

54
const useAuthenticatedFetch = (): typeof fetch => {
65
const { getAccessTokenSilently, loginWithRedirect } = useAuth0();
7-
const location = useLocation();
86

97
return useCallback(
108
async (input: RequestInfo | URL, init?: RequestInit) => {
@@ -13,6 +11,7 @@ const useAuthenticatedFetch = (): typeof fetch => {
1311
try {
1412
accessToken = await getAccessTokenSilently();
1513
} catch {
14+
const { location } = window;
1615
await loginWithRedirect({
1716
appState: {
1817
returnTo: `${location.pathname}${location.search}${location.hash}`,
@@ -29,7 +28,7 @@ const useAuthenticatedFetch = (): typeof fetch => {
2928

3029
return await fetch(input, modifiedInit);
3130
},
32-
[getAccessTokenSilently, loginWithRedirect, location],
31+
[getAccessTokenSilently, loginWithRedirect],
3332
);
3433
};
3534

0 commit comments

Comments
 (0)