反应导航路线参数

React navigation route params

我正在使用 React 导航并想将参数 ID 传递到我的屏幕 RestaurantInfo,但是当我在该屏幕中控制台登录 ID 时,它显示“未定义” 如何正确传递参数,即使遵循了他们以类似方式完成的文档

参数代码:-

   const renderItem = ({ item }) => {
        return (


            <TouchableOpacity style={{ flex: 1 }} key={item.id} onPress={() => navigation.navigate(
                "RestaurantInfo",
                {
                    id: 1
                }
            )}>
                <Card style={{ flex: 1 }}>
                    <Card.Title >{item.name}</Card.Title>
                    <Card.Title>{item.id}</Card.Title>
                    <Card.Image
                        source={{ uri: "https://static.toiimg.com/photo/72975551.cms" }}
                        resizeMode="cover" ></Card.Image>

                    {/*  <Text>
                        <Icon
                            name='email' />
                        Email</Text>
                    <Text> */}


                    <Card.Divider></Card.Divider>
                </Card>
            </TouchableOpacity>

        )
    }

屏幕代码:-

import React from 'react'
import { View, Text } from 'react-native'

export const restaurantInfo = ({ route, navigation }) => {

    console.log(route);
    return (
        <View>
            <Text>Restaurant Info</Text>
        </View>
    )
}

输出:-

Object {
  "key": "restaurantMenu-u_fPFgzRQgEIhM9l1TDtt",
  "name": "restaurantMenu",
  "params": undefined,
}

问题实际上已经解决我尝试将参数从堆栈导航器传递到选项卡导航器因此存在名称不匹配。我还在堆栈导航器中定义了“RestaurantInfo”屏幕所以现在我可以传递paramsstrong文本