React Native 函数headerMode不工作或似乎不存在

djp7away  于 2022-12-30  发布在  React
关注(0)|答案(1)|浏览(171)

我刚拿到代码:

import React from 'react';
import { createStackNavigator } from '@react-navigation/stack';
import { LoginScreen } from '../pages/LoginScreen';
import { CreateAccount } from '../pages/CreateAccount';

const stackRoutes = createStackNavigator();

const AppRoutes: React.FC = () => (
    <stackRoutes.Navigator
        headerMode="none"
        screenOptions={{cardStyle: {backgroundColor: '#FFF'}, }}
    >

        <stackRoutes.Screen
            name="LoginScreen"
            component={LoginScreen}
        />
        <stackRoutes.Screen
            name="CreateAccount"
            component={CreateAccount}
        />

    </stackRoutes.Navigator>
)

export default AppRoutes;

并在“headerMode =“none”中报告了一个错误,我已经做了一些搜索,但我找不到确切的错误。应该用其他方式定义它吗?或者我应该安装一些东西
我已经安装的:yarn add @ react-导航/本地,npx expo安装React-本地-屏幕React-本地-安全-区域-上下文,yarn add @ react-导航/本地-堆栈,yarn add @ react-导航/堆栈和npx expo安装React-本地-手势-处理程序

rekjcdws

rekjcdws1#

我只是做了一些修改,现在它的工作很好,而不是使用headerMode im使用headerShown在screenOptions,所以代码看起来像这样:

import React from 'react';
import { createStackNavigator } from '@react-navigation/stack';
import { LoginScreen } from '../pages/LoginScreen';
import { CreateAccount } from '../pages/CreateAccount';

const stackRoutes = createStackNavigator();

const AppRoutes: React.FC = () => (
    <stackRoutes.Navigator
        /*headerMode="none"*/
        screenOptions={{cardStyle: {backgroundColor: '#FFF'}, headerShown: false}}
    >

        <stackRoutes.Screen
            name="LoginScreen"
            component={LoginScreen}
        />
        <stackRoutes.Screen
            name="CreateAccount"
            component={CreateAccount}
        />

    </stackRoutes.Navigator>
)

export default AppRoutes;

我不知道出了什么问题,也许是新版本改变了,但它现在起作用了。

相关问题