react navigation報錯的解決方法:1、配置“Stack.Navigator initialRouteName="Home"”,然後重啟“yarn android”;2、刪除“android\app\build\outputs\apk\debug”目錄下的打包的apk文件,同時刪除模擬器或真機上原有的apk包,然後重新執行「yarn android」即可。
本教學操作環境:Windows10系統、react18.0.0版、Dell G3電腦。
react navigation報錯怎麼辦?
react-navigation報錯requireNativeComponent: “RNSScreenStackHeaderConfig“ was not found in the UIManage
##App.tsx代碼:import React from 'react'; import { SafeAreaView, ScrollView, StyleSheet, Text, View, } from 'react-native'; import { NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; const Stack = createNativeStackNavigator(); const HomeScreen = () => { return ( <View> <Text>首页</Text> </View> ) } const MyScreen = () => { return ( <View> <Text>我的</Text> </View> ) } const App = () => { return ( <NavigationContainer> <Stack.Navigator initialRouteName="Home"> <Stack.Screen name="Home" component={HomeScreen} /> <Stack.Screen name="Details" component={MyScreen} /> </Stack.Navigator> </NavigationContainer> ); }; const styles = StyleSheet.create({ }); export default App;
<Stack.Navigator initialRouteName="Home"> <Stack.Screen name="Home" component={HomeScreen} /> <Stack.Screen name="Details" component={MyScreen} /> </Stack.Navigator>
react影片教學》
以上是react navigation報錯怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!