banking icon indicating copy to clipboard operation
banking copied to clipboard

{user.name[0]} described as a null value

Open joules65 opened this issue 1 year ago • 3 comments

in the footer section when i compile and run there is an error in the terminal under the name for {user.name[0]} and says cannot read properties of null 'name' even though the file doesn't seem to be screaming over any errors. Eventually the if statement loggedOut for router.push; export const Footer = ({ user, type = 'desktop' }: FooterProps) => { const router = useRouter(); const handleLogOut = async () => { const loggedOut = await logoutAccount();

if(loggedOut) router.push('/sign-in')

} the loggedOut is flaring and says an expression of type void cannot be tested for truthiness(if that's even a correct statement).

joules65 avatar Sep 04 '24 22:09 joules65

Screenshot (69)

joules65 avatar Sep 04 '24 23:09 joules65

when you go to home page directly without sign in or sign up it will through a null value. To go to the logged in user you have to sign in by going. http://localhost:3000/sign-in. http://localhost:3000/sign-up. Then log in using the email and password. then you will be directed to your dashboard. start working from there. also in the layout.tsx root component. const loggedIn = await getLoggedInUser(); if (!loggedIn) redirect("/sign-in");

and watch the video completely

Aniket-Sharmaa avatar Sep 11 '24 07:09 Aniket-Sharmaa

OMG ! THANK YOU ShadowRoot-ops.I had the same issue with user.name[0] being null in the RightSidebar.tsx. Could not understand what is wrong with syntax for 3 days. First ,I thought there was some issue with index.d.ts but all you need to do is actually create new "user" by first sign-up and then sign-in

StackTheCode avatar Sep 21 '24 13:09 StackTheCode