React Native 中的放大身份验证可在带有 Web 视图的 Expo Go 上运行,但不适用于 iOS 或 Android

问题描述 投票:0回答:2

我试图在 React Native 中使用“withAuthenticator”和 Amplify 来让身份验证与我的简单应用程序一起使用,但我在 iOS 和 Android 上都遇到了错误,但对于 Web 视图,身份验证工作完美。

在iOS和Android上通过扫描Expo Go的二维码进行测试时,遇到以下错误(网页视图没有此错误):

Render Error
Text strings must be rendered within a <Text> component.
<WrappedWithAuthenticator /> 
withDevTools.ios.js:25 
<withDevTools(WrappedWithAuthenticator)/> 
renderApplication.js:57
5 more components

这是我的 App.js 代码:

import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';

import { Amplify } from 'aws-amplify';
import { withAuthenticator } from '@aws-amplify/ui-react';
import amplifyconfig from './src/amplifyconfiguration.json';

Amplify.configure(amplifyconfig);


import HomeScreen from './Screens/Home';
import DetailsScreen from './Screens/Details';


const Stack = createNativeStackNavigator();

const App = () => {

  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName = "Home" >
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Details" component={DetailsScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );

};

export default withAuthenticator(App);

如有任何帮助,我们将不胜感激!

我尝试了一些随机的解决方案,例如导入文本、按钮、TouchableOpacities 等,但这没有用。

我已将问题范围缩小到放大身份验证,因为当身份验证不在应用程序中时,应用程序可以在 iOS 和 Android 上正常运行。

这是一个非常奇怪的问题,因为它在网络上测试时工作正常,但在 iOS 或 Android 上不起作用。

react-native expo aws-amplify expo-go
2个回答
0
投票

Expo Go 与 AWS Amplify V6 存在一些兼容性问题。如果可以的话,尽量坚持使用版本 5。问题仍然存在,我花了几天时间试图解决它,但徒劳无功。 尽管如此,尝试使用 --legacy-peer-deps 安装你的包,它可能会帮助你。我尝试了结果是随机的。所以我放弃了世博会,直到事情变得更加清晰。


0
投票

我在这里遇到了类似的问题,尝试解决该问题已经两天了,但找不到解决方案。 我正在考虑降级 Amplify 版本。

© www.soinside.com 2019 - 2024. All rights reserved.