adrianhajdin / banking

Horizon is a modern banking platform for everyone.
https://banking-jet.vercel.app
MIT License
2.05k stars 636 forks source link

RightSidebar - TypeError: Cannot read properties of null (reading 'name') #66

Open Lame-Dolphin opened 1 month ago

Lame-Dolphin commented 1 month ago

image

Been following the tutorial but got stuck here. Unable to identify what is the reason it's reading null from name.

Ener03 commented 1 month ago

Actually i have solved... or rather escaped it somehow but, it delete some of the content of the card in the right sidebar. Still trying to solve it like in the tutorial but no luck yet... so see if this one go for you, not sure if it helps.

<span className="text-5xl font-bold text-blue-500">{user?.name?.[0]}</span>
      </div>

      <div className="profile-details">
        <h1 className='profile-name'>
          {user?.name}
        </h1>
        <p className="profile-email">
          {user?.email}
        </p>

    </div>
    {banks?.length > 0 && (
      <div className="relative flex flex-1 flex-col items-center justify-center gap-5">
        <div className='relative z-10'>
          <BankCard 
            key={banks[0].$id}
            account={banks[0]}
            userName={user?.name}
            showBalance={false}
          />
        </div>
        {banks[1] && (
          <div className="absolute right-0 top-8 z-0 w-[90%]">
            <BankCard 
              key={banks[1].$id}
              account={banks[1]}
              userName={user?.name}
              showBalance={false}
            />
          </div>

i just put a ? inbetween of every user and .name

Lame-Dolphin commented 1 month ago

Hey man, thanks for your help! This actually helped to escape that error. But have you gotten any idea why is it this way? The tutorial doesn't seem to encounter this issue.

Ener03 commented 1 month ago

No problem, if i could help you it all that matters but it was after i made some research in the documentation and chat that i could have that so i can't really take credit for it, cause me i'm kind of an beginner. then again hope i can better and handle this more efficiently. -_-

FaVstarr commented 1 month ago

t

image

Been following the tutorial but got stuck here. Unable to identify what is the reason it's reading null from name.

I encountered this too, check your .env use the NEXT_APPWRITE_KEY= then, ensure that you're logged in as a user, i.e user is not undefined, so maybe sign-up and sign-in again, should fix the issue, or add the optional symbol '?' so that your code won't break, that is making the user? optional, but better still, if you follow up the tutorial a bit further you see where in the root layout an if statement is added to see if the user is logged in