我需要将功能组件更改为类组件。我知道该怎么做,但是如果我想传递道具怎么办?
功能组件
const FunctionalComponent = (props) => {
return (
<View>
<View>
<TouchableOpacity
onPress={()=> {props.navigation.navigate('profile')}}>
<Text>button</Text>
</TouchableOpacity>
</View>
<ScrollView>
<DrawerItems {...props}/>
</ScrollView>
</View>
)
}
类组件
class ClassComponent extends Component = (props) => {
render(){
return (
<View>
<View>
<TouchableOpacity
onPress={()=> {props.navigation.navigate('profile')}}>
<Text>button</Text>
</TouchableOpacity>
</View>
<ScrollView>
<DrawerItems {...props}/>
</ScrollView>
</View>
)
}
}
我尝试过此操作,但这将引发错误。