File tree 1 file changed +12
-11
lines changed
1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -77,24 +77,25 @@ export const V2Navbar = () => {
77
77
const [ isOpen , setIsOpen ] = React . useState ( false ) ;
78
78
const { user, loading } = useAuth ( ) ;
79
79
const router = useRouter ( ) ;
80
+ const [ authState , setAuthState ] = React . useState ( { user, loading } ) ;
81
+
82
+ React . useEffect ( ( ) => {
83
+ setAuthState ( { user, loading } ) ;
84
+ } , [ user , loading ] ) ;
80
85
81
86
const handleSignOut = async ( ) => {
82
87
await signout ( ) ;
83
- router . push ( ' /auth/signin' ) ;
88
+ router . push ( " /auth/signin" ) ;
84
89
} ;
85
90
86
91
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 ;
96
93
97
- return (
94
+ return authState . user ? (
95
+ < Button onClick = { handleSignOut } className = "rounded-2xl" >
96
+ Sign Out
97
+ </ Button >
98
+ ) : (
98
99
< >
99
100
< Link href = "/auth/register" >
100
101
< Button className = "rounded-2xl" > Register</ Button >
You can’t perform that action at this time.
0 commit comments