如何将React Native代码从0.59.10版本转换到0.72.5版本?

bd1hkmkf  于 2023-10-22  发布在  React
关注(0)|答案(1)|浏览(206)

我在initialRouteName上收到错误:'Notifications' property,和我尝试了几种解决方案,但都没有成功。我是React Native的新手,我希望得到任何帮助。

const NotificationStackNavigator = createStackNavigator(
  {
      Notifications:{                           //PAGE: To-Do => List Of Leave
          screen: Notification,
          navigationOptions:{
              title: 'Notifications'
          }
      },
      //#region Leave Application
      AllApprovalInToDo: {                      //PAGE: To-Do => All List Of Leave
          screen: AllApprovalInToDo,
          navigationOptions: {
            title: 'Approval Leave Request',
            headerBackTitle: 'Back',
            headerStyle:{
                backgroundColor: Blue,
            },
            headerTintColor: '#fff',
            headerTitleStyle: {
                fontWeight: 'normal'
            }
        }
      },
      ApprovalItem: {                         //PAGE: To-Do => Leave Detail
        screen: ApprovalItem,
      },
      LeaveApprovalToDoFilter: {              //PAGE: To-Do => Leave Filter
        screen: PendingLeaveApprovalFilter
      },
      //#endregion Leave Application
      //#region Overtime
      OvertimeApprovalDetail: {               //PAGE: To-Do => Overtime Detail
        screen: OvertimeApprovalDetail
      },
      OvertimeAllApproval: {                  //PAGE: To-Do => All List of Overtime
        screen: OvertimeAllApproval
      },
      OvertimeApprovalFilter: {               //PAGE: To-Do => Overtime Filter Page
        screen: OvertimeApprovalFilter
      }
      //#endregion Overtime
  },
  {
      initialRouteName: 'Notifications',
  },
);

Screenshot of problem
当我尝试将React Native代码从0.59.10版本转换到0.72.5版本时,我收到了错误initialRouteName:通知我该怎么办?

laximzn5

laximzn51#

在这里,您可以创建一个导航器。你也需要更新你的react-navigation到最新版本。

import { createNativeStackNavigator } from '@react-navigation/native-stack';
import React from 'react';
import fonts from '../constants/fonts';
import { moderateScale } from '../constants/scaling';
import theme from '../constants/theme';
import DialPadScreen from '../screens/DialPadScreen';
import GettingStartedScreen from '../screens/GettingStartedScreen';
import PrivacyPolicyScreen from '../screens/PrivacyPolicyScreen';
import SearchScreen from '../screens/SearchScreen';
import SearchScreenResults from '../screens/SearchScreenResults';
import UserProfileRegisterationScreen from '../screens/UserProfileRegisterationScreen';
const Stack = createNativeStackNavigator();
function AuthStack() {
    return (
    <Stack.Navigator
      initialRouteName={"GettingStartedScreen"}
      screenOptions={{
        headerTintColor: theme.primaryColor,
        headerBackTitleVisible: false,
        headerTitleStyle: {
          fontFamily: fonts.Bold,
          fontSize: moderateScale(16),
          color: theme.primaryColor,
        },
        headerBackTitleStyle: {
          color: theme.primaryColor,
        },
        animation:"slide_from_right",
        animationDuration:5000,
        headerShown: true,
      }}>
      <Stack.Screen
        name="GettingStartedScreen"
        options={{headerShown: false}}
        component={GettingStartedScreen}
      />
      <Stack.Screen
        name="PrivacyPolicyScreen"
        options={{title: 'Privacy Policy'}}
        component={PrivacyPolicyScreen}
      />
      <Stack.Screen
        name="UserProfileRegisterationScreen"
        component={UserProfileRegisterationScreen}
        options={{title: 'User Register Profile'}}
      />
      <Stack.Screen
        name="SearchScreen"
        component={SearchScreen}
        options={{title: 'Phone Caller ID'}}
      />
      <Stack.Screen
        name="DialPadScreen"
        component={DialPadScreen}
        options={{title: 'Dial Paid'}}
      />

      <Stack.Screen
        name="SearchScreenResults"
        component={SearchScreenResults}
        options={{title: 'Search Results'}}
      />
    </Stack.Navigator>
  );
}

export default AuthStack;

相关问题