File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -77,24 +77,25 @@ export const V2Navbar = () => {
7777 const [ isOpen , setIsOpen ] = React . useState ( false ) ;
7878 const { user, loading } = useAuth ( ) ;
7979 const router = useRouter ( ) ;
80+ const [ authState , setAuthState ] = React . useState ( { user, loading } ) ;
81+
82+ React . useEffect ( ( ) => {
83+ setAuthState ( { user, loading } ) ;
84+ } , [ user , loading ] ) ;
8085
8186 const handleSignOut = async ( ) => {
8287 await signout ( ) ;
83- router . push ( ' /auth/signin' ) ;
88+ router . push ( " /auth/signin" ) ;
8489 } ;
8590
8691 const renderAuthButtons = ( ) => {
87- if ( loading ) return null ;
88-
89- if ( user ) {
90- return (
91- < Button onClick = { handleSignOut } className = "rounded-2xl" >
92- Sign Out
93- </ Button >
94- ) ;
95- }
92+ if ( authState . loading ) return null ;
9693
97- return (
94+ return authState . user ? (
95+ < Button onClick = { handleSignOut } className = "rounded-2xl" >
96+ Sign Out
97+ </ Button >
98+ ) : (
9899 < >
99100 < Link href = "/auth/register" >
100101 < Button className = "rounded-2xl" > Register</ Button >
You can’t perform that action at this time.
0 commit comments