reactjs React Navigation I需要本机组件:“RNSS屏幕堆栈标头配置”

yvfmudvl  于 2023-03-08  发布在  React
关注(0)|答案(4)|浏览(219)

我刚开始我的新项目。安装react-navigation并在我的IOS应用程序中使用后,我得到了一个错误Invariant Violation: requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager.。我无法找出问题所在。
这是我的导航代码

import React from 'react';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import strings from '../Constants/Strings';
import {Home} from '../Screens';

const Stack = createNativeStackNavigator();

export default MainStack = () => {
  return (
    <Stack.Navigator>
      <Stack.Screen name={strings.navHome} component={Home} />
    </Stack.Navigator>
  );
};
import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import MainStack from './MainStack';

const Routes = () => {
  return (
    <NavigationContainer>
      <MainStack />
    </NavigationContainer>
  );
};

export default Routes;

谁能告诉我是什么问题?我以前从来没有遇到过这样的错误

gstyhher

gstyhher1#

如果您正在使用**@react-navigation/native-stack**,则还应安装react-native-screensreact-native-safe-area-context。我认为您的错误是因为您尚未安装react-native-screens
检查documentation

8zzbczxx

8zzbczxx2#

我安装了@react-navigation/native-stackreact-native-safe-area-contextreact-native-screens
但具有相同的误差

Invariant Violation: requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager
vddsk6oq

vddsk6oq3#

以前必须已安装。

@react-navigation/native-stack
react-native-safe-area-context
react-native-screens

此外,请尝试清除该高速缓存并重新编译应用。

watchman watch-del-all && rm -rf node_modules
yarn cache clean && yarn
npx pod-install
yarn start --reset-cache

之后,您可以尝试使用以下选项运行应用:

yarn run ios
mpgws1up

mpgws1up4#

安装吊舱对我起作用了!!

npx pod-install

相关问题