Hi i am trying to pass firstname and lastname in function call when inside jsx but I always get a declaration error as a return how can you help me with this task
I ended up just calling it inside the h2 tag like this :

export const element = () => {
return <div>
<div>Welcome on board</div>
<h2>{getUser()}</h2>
</div>
};

But I get an error saying:

  1. {firstName} {lastName} (field of object returned by getUser) should be the inner text of the h2 heading

Thank you in advance!!

  • Coderslang_Master replied to this.
  • eri the call to getUser() returns an object. Then, you should use 2 fields of this object and output them in the H2 header:

    const user = getUser();
    ....
          <h2>
            {user.firstName} {user.lastName}
          </h2>
    ....

    eri the call to getUser() returns an object. Then, you should use 2 fields of this object and output them in the H2 header:

    const user = getUser();
    ....
          <h2>
            {user.firstName} {user.lastName}
          </h2>
    ....
    • eri replied to this.
      5 days later
      Write a Reply...