Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Lame-Dolphin opened this issue Sep 26, 2024 · 6 comments

Comments

@Lame-Dolphin
Copy link

image

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

@Ener03
Copy link

Ener03 commented Sep 28, 2024

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
Copy link
Author

Lame-Dolphin commented Oct 2, 2024

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
Copy link

Ener03 commented Oct 2, 2024

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
Copy link

FaVstarr commented Oct 4, 2024

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

@acubeos
Copy link

acubeos commented Dec 4, 2024

Has anyone been able to solve this?

@acubeos
Copy link

acubeos commented Dec 6, 2024

Finally, I solved it! It is right from Appwrite. When creating the user attributes, I made a mistake of using string for email instead of Email. Once corrected, restart your the project, sign up and then sign in. You are good to go. Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants