首页 > 解决方案 > 使用 AmplifyGreetings 显示用户名

问题描述

我有一个使用 Amazon Amplify 框架开发的反应应用程序。根据文档,我试图在Signout按钮之前检索我的用户名(我在注册过程中指定的)。该文档没有明确说明如何显示我的用户名,因为该<AmplifyGreetings>组件放置了一个用户名的虚拟属性。有人可以指导我如何做到这一点吗?

代码:App.js

import React from "react";
import { withAuthenticator, AmplifyGreetings } from "@aws-amplify/ui-react";
class App extends React.Component {
  render() {
    return (
      <div>
        <AmplifyGreetings username="retrieve your username here"></AmplifyGreetings>
      </div>
    );
  }
}

export default withAuthenticator(App);

这就是我的输出的样子。 在此处输入图像描述

标签: reactjsamazon-web-servicesamazon-cognitoaws-amplify

解决方案


推荐阅读