[英]Access Props inside const in React Native - Javascript
我创建了一个这样的常量:
const DrawerNav = DrawerNavigator({
Home:{
screen:StackNav,
navigationOptions: {
drawerLockMode: 'locked-closed'
}
},
MonthlyReport: {
screen:MonthlyReport
}
},{
contentComponent: () => <DrawerContent item={props.item}/>
})
现在,我使用以下命令访问它:
<DrawerNav item={item}/>
但是我无法访问DrawerNav
内部传递的道具。 如何在以下位置访问此文件:
<DrawerContent item={props.item}/>
您忘记获取prop参数:
contentComponent: props => (
<DrawerContent {...props} />
)
然后只需使用散布运算符
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.