我试图在 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 上不起作用。
Expo Go 与 AWS Amplify V6 存在一些兼容性问题。如果可以的话,尽量坚持使用版本 5。问题仍然存在,我花了几天时间试图解决它,但徒劳无功。 尽管如此,尝试使用 --legacy-peer-deps 安装你的包,它可能会帮助你。我尝试了结果是随机的。所以我放弃了世博会,直到事情变得更加清晰。
我在这里遇到了类似的问题,尝试解决该问题已经两天了,但找不到解决方案。 我正在考虑降级 Amplify 版本。