本文小编为大家详细介绍“react navigation报错如何解决”,内容详细,步骤清晰,细节处理妥当,希望这篇“react navigation报错如何解决”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
react navigation报错的解决办法:1、配置“Stack.Navigator initialRouteName="Home"”,然后重启“yarn android”;2、删除“androidappuildoutputsapkdebug”目录下的打包的apk文件,同时删除模拟器或真机上原有的apk包,然后重新执行“yarn android”即可。
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",且配置至少2个Stack.Screen 页面。
步骤:然后重启yarn android。如果仍然报错requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager,则需要删除androidappuildoutputsapkdebug目录下的打包的apk文件,同时删除模拟器或真机上原有的apk包。然后重新yarn android,生成打包apk,拖到到夜神模拟器,或者真机上测试。
如果仍然报错,可能需要反复上面的步骤(这边反复4次才成功)。
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Details" component={MyScreen} />
</Stack.Navigator>
版权声明:除特别声明外,本站所有文章皆是本站原创,转载请以超链接形式注明出处!