import React, {Component} from 'react';
import {Text, View, TouchableOpacity} from 'react-native';
export default class Parent extends Component {
onRef = (ref) => {
this.child = ref
}
clickcs = (e) => {
this.child.myName()
}
render() {
return(
<View>
<Child onRef={this.onRef} />
<TouchableOpacity onPress={this.clickcs} >
<Text>click</Text>
</TouchableOpacity>
</View>
)
}
}
class Child extends Component {
componentDidMount(){
this.props.onRef(this)
}
myName = () =>{
alert(11111111111111)
}
render() {
return (<View></View>)
}
}