0
我從(父組件)的ListView導航:如何調用從父列表視圖中的子組件的功能
rowPressed(element) {
this.props.navigator.push({
title: element.title,
rightButtonSystemIcon: 'action',
onRightButtonPress:() => {
// how to call my function _handleRightButtonPress() ?
},
component: ElementDetail,
passProps: {
element: element
}
});
}
我想在ElementDetail組件調用_handleRightButtonPress():
class ElementDetail extends Component {
constructor(props) {
super(props);
...
}
_handleRightButtonPress() {
console.log('right Button Pressed');
};
...
}
任何想法如何做到這一點?
謝謝。但是我怎樣才能從位於父類的「onRightButtonPress」的子組件中調用此函數? – peter
您可以使用react-redux併發送一些數據,一旦組件通過redux接收道具,將會沿着這些數據調用子組件。 – Vicky