File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
npm-packages/docs/docs/auth/authkit Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -438,7 +438,7 @@ Next.js app with Convex. If not follow the
438438 ``` tsx title="components/ConvexClientProvider.tsx"
439439 ' use client' ;
440440
441- import { ReactNode , useCallback , useRef } from ' react' ;
441+ import { ReactNode , useCallback , useEffect , useRef } from ' react' ;
442442 import { ConvexReactClient } from ' convex/react' ;
443443 import { ConvexProviderWithAuth } from ' convex/react' ;
444444 import { AuthKitProvider , useAuth , useAccessToken } from ' @workos-inc/authkit-nextjs/components' ;
@@ -462,9 +462,11 @@ Next.js app with Convex. If not follow the
462462 const authenticated = !! user && !! accessToken && ! loading ;
463463
464464 const stableAccessToken = useRef <string | null >(null );
465- if (accessToken && ! tokenError ) {
466- stableAccessToken .current = accessToken ;
467- }
465+ useEffect (() => {
466+ if (accessToken && ! tokenError ) {
467+ stableAccessToken .current = accessToken ;
468+ }
469+ }, [accessToken , tokenError ]);
468470
469471 const fetchAccessToken = useCallback (async () => {
470472 if (stableAccessToken .current && ! tokenError ) {
You can’t perform that action at this time.
0 commit comments