【发布时间】:2021-01-07 18:01:42
【问题描述】:
我正在使用带有 react navigation5 的类组件,我有两个类:
类 DrawerComponent.js
export default class DrawerContent extends Component{
constructor(props){
super(props);
}
render(){
return(
<View style={{flex:1}}>
<DrawerContentScrollView {...this.props}>
<Drawer.Section style={styles.drawerSection}>
{
<DrawerItem
icon={({color,size}) => (
<Icon
name=""
color={color}
size={size}
/>
)}
label={menu.localizedTitle}
onPress = {() =>**{this.props.navigation.navigate("RecordList",{body :'abc' }**)}}/>)
</Drawer.Section>
</View>
</DrawerContentScrollView>
</View>
)}}
现在如果我必须在另一个类中访问 body 的值,我该怎么做?
【问题讨论】:
-
我得到一个错误 getParam is not a func
-
对不起,我的错。你说 react-navigation 5,它适用于 v4。 Ketan 的回答是有效的。
标签: react-native react-navigation react-navigation-v5