Home > Web Front-end > Front-end Q&A > What to do if react navigation reports an error

What to do if react navigation reports an error

藏色散人
Release: 2022-12-30 10:35:28
Original
2394 people have browsed it

Solution to react navigation error: 1. Configure "Stack.Navigator initialRouteName="Home"", and then restart "yarn android"; 2. Delete "android\app\build\outputs\apk\debug" directory, delete the original apk package on the emulator or real machine, and then re-execute "yarn android".

What to do if react navigation reports an error

The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.

What should I do if I get an error in react navigation?

react-navigation error requireNativeComponent: “RNSScreenStackHeaderConfig“ was not found in the UIManage

App.tsx code:

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;
Copy after login

Configuration: Stack.Navigator initialRouteName=" Home", and configure at least 2 Stack.Screen pages.

Steps: Then restart yarn android. If the error requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager is still reported, you need to delete the packaged apk file in the android\app\build\outputs\apk\debug directory, and delete the original apk package on the emulator or real device. Then re-yarn Android, generate a packaged apk, and drag it to the Yeshen emulator or a real device for testing.

If the error is still reported, you may need to repeat the above steps (repeated 4 times before success).

<Stack.Navigator initialRouteName="Home">
   <Stack.Screen name="Home" component={HomeScreen} />
   <Stack.Screen name="Details" component={MyScreen} />
</Stack.Navigator>
Copy after login

Recommended learning: "react video tutorial"

The above is the detailed content of What to do if react navigation reports an error. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template