react-native - 未找到 AWS 放大 react-native IdentityPool
问题描述
我正在尝试使用 AWS amplify 实现基本身份验证,当前代码没有给我红屏或警告。使用 console.log 的唯一一行显示了这一点
IdentityPool 'eu-west-1:fbbc514e-e3eb-4176-855c-d0fae5a0eca4' not found. at node_modules/@aws-sdk/client-cognito-identity/dist/cjs/protocols/Aws_json1_1.js:803:40 in deserializeAws_json1_1GetIdCommandError
import React, { useState, useEffect } from 'react'
import { StyleSheet, Text, View, Button } from 'react-native'
import Amplify, { Auth, Hub } from 'aws-amplify'
import awsconfig from './src/aws-exports'
Amplify.configure(awsconfig)
export default function App () {
const [user, setUser] = useState('')
const [isLoggedIn, setIsLoggedIn] = useState(false)
useEffect(() => {
Hub.listen('auth', ({ payload: { event, data } }) => {
console.log(data)
switch (event) {
case 'signIn':
setUser(data)
setIsLoggedIn(true)
console.log('User logged in: ', data)
break
case 'signOut':
setUser('')
setIsLoggedIn(false)
console.log('User logged out: ', data)
break
case 'customOAuthState':
setUser(data)
}
})
}, []) //call Hub listen only on component mount & unmount
return (
<React.Fragment>
{isLoggedIn ? (
<View style={styles.container}>
<Text>User logged in as {user.username}</Text>
</View>
) : (
<View style={styles.container}>
<Button
title='FacebookSignIn'
onPress={() => {
Auth.federatedSignIn({ provider: 'Facebook' })
}}
/>
</View>
)}
</React.Fragment>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center'
}
})
请指教
解决方案
推荐阅读
- c++ - std::accumulate 可以抛出吗?
- excel - 如何在 VBA 中找到控件的父用户窗体
- javascript - Await 仅在异步函数中有效
- excel - 如何验证电子邮件地址格式?
- google-cloud-platform - 在 GCP 中查询项目列表
- string - 恐慌:运行时错误:切片超出范围 [2:1]
- c# - C#:运行程序并用 if 语句回答输入后,我如何让程序继续提问?
- kubernetes - 如何在 GCP 中启用 Kubernetes API?没有按照文档在这里整理
- nginx - 使用 Terraform 在没有“remote_exec”的情况下安装 NGINX
- python - 从 div 类中收集链接