Skip to content

Commit 243edb2

Browse files
committed
Set skipInitialFetch to true and remove from authprovider
1 parent bea7372 commit 243edb2

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/AuthContext.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export type AuthProviderProps = {
5656
getActiveOrgFn?: () => string | null
5757
children?: React.ReactNode
5858
minSecondsBeforeRefresh?: number
59-
skipInitialFetch?: boolean
6059
}
6160

6261
export interface RequiredAuthProviderProps
@@ -106,7 +105,6 @@ export const AuthProvider = (props: AuthProviderProps) => {
106105
const {
107106
authUrl,
108107
minSecondsBeforeRefresh,
109-
skipInitialFetch,
110108
getActiveOrgFn: deprecatedGetActiveOrgFn,
111109
children,
112110
defaultDisplayWhileLoading,
@@ -116,7 +114,6 @@ export const AuthProvider = (props: AuthProviderProps) => {
116114
const { clientRef, accessTokenChangeCounter } = useClientRef({
117115
authUrl,
118116
minSecondsBeforeRefresh,
119-
skipInitialFetch
120117
})
121118

122119
// Refresh the token when the user has logged in or out

src/useClientRef.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ type ClientRef = {
99
interface UseClientRefProps {
1010
authUrl: string
1111
minSecondsBeforeRefresh?: number
12-
skipInitialFetch?: boolean
1312
}
1413

1514
export const useClientRef = (props: UseClientRefProps) => {
1615
const [accessTokenChangeCounter, setAccessTokenChangeCounter] = useState(0)
17-
const { authUrl, minSecondsBeforeRefresh, skipInitialFetch } = props
16+
const { authUrl, minSecondsBeforeRefresh } = props
1817

1918
// Use a ref to store the client so that it doesn't get recreated on every render
2019
const clientRef = useRef<ClientRef | null>(null)
2120
if (clientRef.current === null) {
22-
const client = createClient({ authUrl, enableBackgroundTokenRefresh: true, minSecondsBeforeRefresh, skipInitialFetch })
21+
const client = createClient({ authUrl, enableBackgroundTokenRefresh: true, minSecondsBeforeRefresh, skipInitialFetch: true })
2322
client.addAccessTokenChangeObserver(() => setAccessTokenChangeCounter((x) => x + 1))
2423
clientRef.current = { authUrl, client }
2524
}
@@ -33,7 +32,7 @@ export const useClientRef = (props: UseClientRefProps) => {
3332
} else {
3433
clientRef.current.client.destroy()
3534

36-
const newClient = createClient({ authUrl, enableBackgroundTokenRefresh: true, minSecondsBeforeRefresh, skipInitialFetch })
35+
const newClient = createClient({ authUrl, enableBackgroundTokenRefresh: true, minSecondsBeforeRefresh, skipInitialFetch: true })
3736
newClient.addAccessTokenChangeObserver(() => setAccessTokenChangeCounter((x) => x + 1))
3837
clientRef.current = { authUrl, client: newClient }
3938
}

0 commit comments

Comments
 (0)