question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Logo passed in to AmplifyGreetings is not rendered

See original GitHub issue

Describe the bug I am trying to customize the AmplifyGreetings component in my React app. I’m using the instructions at the official amplify docs.

I am using "@aws-amplify/ui-react": "^0.2.8".

I am passing props to the AmplifyGreetings component in my App.js like so: <AmplifyGreetings logo={Hello} username={userEmail}></AmplifyGreetings>, just as described in the docs. However the logo never displays, it’s always undefined (see screenshot below).

To Reproduce Steps to reproduce the behavior:

Here’s a more complete example:

const App = () => {
  const Hello = () => <h1>Hello!</h1>

  return (
    <AmplifyAuthenticator usernameAlias='email'>
      <AmplifySignIn
        headerText='Sign In to Your Account'
        slot='sign-in'
      ></AmplifySignIn>
      <AmplifyGreetings logo={Hello} username="abc@example.com"></AmplifyGreetings>
      <div className='App'>
      // nothing special here, just a form and a button
      </div>
    </AmplifyAuthenticator>
  )
}

In my App.css I have managed to customize the colors using:

amplify-greetings {
  --background-color: #02387b;
  --border-color: #02387b;
  color: #eff0f4;

}

Expected behavior

I actually want to pass in an SVG component to the logo prop of AmplifyGreetings. I am able to import a logo component like so: import svglogo from './logo/svglogo' and render svglogo inside <div className='App'>. In other words, I know the SVG component is working and I am able to show it in the app, but it doesn’t work in AmplifyGreetings.

The docs for AmplifyGreetings say: docs

The problem with the above docs is that FunctionalComponent<{}> is really very ambiguous, and I have been scouring the Internet on how to pass this FunctionalComponent<{}> logo to AmplifyGreetings, but haven’t been able to find a single example. As you can see from the snippet I shared above, const Hello = () => <h1>Hello!</h1> is a simple, purely-functional React component, but even this is also getting rendered as undefined. There is no help from Amplify’s console logs on what I am doing wrong - no warnings or errors or feedback of any kind. This is very frustrating.

I am blocked on this issue, because I have to get my client’s logo rendered in the header. So I would immensely appreciate it if you could please share a working example of passing a sample logo FunctionalComponent<{}> (whatever that is supposed to be) to AmplifyGreetings.

Expected: The functional logo component I am passing in to AmplifyGreetings should get rendered, instead of the undefined that is displayed. OR please share a working example for me to emulate, in case I am not using the right Type when passing the prop to AmplifyGreetings. OR please suggest a suitable workaround for now.

Code Snippet Shared above (in Steps to Reproduce)

Screenshots Please see this: this screenshot

What is Configured? If applicable, please provide what is configured for Amplify CLI:

  • Which steps did you follow via Amplify CLI when configuring your resources.
  • Which resources do you have configured? Not required, imo, because auth is working functionally: sign-up, sign-in, sign-out are working fine. The problem is limited to passing a logo to AmplifyGreetings and having it rendered correctly.

Smartphone (please complete the following information): N/A

Additional context None.

You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = ‘DEBUG’; in your app.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
nonbeingcommented, Aug 9, 2020

Confirmed the fix using "@aws-amplify/ui-react": "^0.2.15-unstable.2" and "aws-amplify": "^3.0.23".

Relevant code:

import logo from './logo/Nautical_star.svg'
.
.
.
      <AmplifyGreetings username={userEmail}>
        <img slot="logo" src={logo} height="60" width="60" />
      </AmplifyGreetings>

Screenshot: screenshot

Thanks @jordanranz ! 👍👍

When is this fix likely to make it to the mainline?

1reaction
nonbeingcommented, Aug 7, 2020

Sure, will try to do this today or tomorrow. Thanks @jordanranz

Read more comments on GitHub >

github_iconTop Results From Across the Web

'AmplifySignOut' is not exported from '@aws-amplify/ui-react'
I can add import '@aws-amplify/ui-react/styles.css'; and I get some styling back, but I really need things back to how the were working. Any ......
Read more >
Authenticator - React - Amplify Docs
A simple way to add authentication flows into your app is to use the Authenticator component. The Authenticator component encapsulates an authentication ...
Read more >
Amplify UI's new Authenticator component makes it easy to ...
In this blog post we will deploy a React app with Amplify Hosting, set up auth, and then integrate the <Authenticator> UI component...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found