Llamar a la función secundaria desde el componente principal en React Native
Estoy desarrollando mi primera aplicación React Native. Lo que intento lograr es ejecutar una función secundaria desde el componente principal, esta es la situación:
Niño
export default class Child extends Component {
...
myfunct: function() {
console.log('Managed!');
}
...
render(){
return(
<Listview
...
/>
);
}
}
Padre
export default class Parent extends Component {
...
execChildFunct: function() {
...
//launch child function "myfunct"
...
//do other stuff
}
render(){
return(
<View>
<Button onPress={this.execChildFunct} />
<Child {...this.props} />
</View>);
}
}
En este ejemplo, me gustaría iniciar sesión'Managed!'
cuando presiono el botón en la clase principal. ¿Cómo es factible?