@@ -9,16 +9,17 @@ type ClientRef = {
99interface UseClientRefProps {
1010 authUrl : string
1111 minSecondsBeforeRefresh ?: number
12+ skipInitialFetch ?: boolean
1213}
1314
1415export const useClientRef = ( props : UseClientRefProps ) => {
1516 const [ accessTokenChangeCounter , setAccessTokenChangeCounter ] = useState ( 0 )
16- const { authUrl, minSecondsBeforeRefresh } = props
17+ const { authUrl, minSecondsBeforeRefresh, skipInitialFetch } = props
1718
1819 // Use a ref to store the client so that it doesn't get recreated on every render
1920 const clientRef = useRef < ClientRef | null > ( null )
2021 if ( clientRef . current === null ) {
21- const client = createClient ( { authUrl, enableBackgroundTokenRefresh : true , minSecondsBeforeRefresh } )
22+ const client = createClient ( { authUrl, enableBackgroundTokenRefresh : true , minSecondsBeforeRefresh, skipInitialFetch } )
2223 client . addAccessTokenChangeObserver ( ( ) => setAccessTokenChangeCounter ( ( x ) => x + 1 ) )
2324 clientRef . current = { authUrl, client }
2425 }
@@ -32,7 +33,7 @@ export const useClientRef = (props: UseClientRefProps) => {
3233 } else {
3334 clientRef . current . client . destroy ( )
3435
35- const newClient = createClient ( { authUrl, enableBackgroundTokenRefresh : true , minSecondsBeforeRefresh } )
36+ const newClient = createClient ( { authUrl, enableBackgroundTokenRefresh : true , minSecondsBeforeRefresh, skipInitialFetch } )
3637 newClient . addAccessTokenChangeObserver ( ( ) => setAccessTokenChangeCounter ( ( x ) => x + 1 ) )
3738 clientRef . current = { authUrl, client : newClient }
3839 }
0 commit comments