首先,我已经使用成功完成了我的反应应用程序的配置amplify configure
。我在以下人员的帮助下做到了AWS 放大文档 https://docs.amplify.aws/cli/start/install。然后我已成功将身份验证添加到我的放大项目中,使用amplify add auth
and amplify push
。我按照中的所有步骤进行了操作AWS - 使用 Amplify Doc 进行身份验证 https://docs.amplify.aws/lib/auth/getting-started/q/platform/js
My App.js
看起来像这样,
import React from 'react';
import { withAuthenticator, AmplifySignOut } from '@aws-amplify/ui-react';
import Amplify, { Auth } from 'aws-amplify';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
const App = () => (
<div>
<AmplifySignOut />
My App
</div>
);
export default withAuthenticator(App);
But when I try npm start
, it shows the following error,
我在这个找到了这个问题的解决方案github 问题 https://github.com/aws-amplify/amplify-js/issues/4315
修复方法很简单。 Amplify 文档不会告诉您加载配置aws-exports
to Auth module
.
添加这行简单的代码App.js
,为我解决了这个问题。
import Amplify, { Auth } from 'aws-amplify';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
// >>New - Configuring Auth Module
Auth.configure(awsconfig);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)