import React, {Component} from 'react';
import {Text, View, TouchableOpacity} from 'react-native';
// 父
let child
onRefbbb = (ref) => {
child = ref
}
clickccc = () => {
child.myName()
}
const Parent =()=> {
return(
<View>
<Child onRefaaa={onRefbbb} />
<TouchableOpacity onPress={()=>clickccc()}>
<Text>onClick</Text>
</TouchableOpacity>
</View>
)
}
export default Parent
// 子
class Child extends Component {
componentDidMount(){
this.props.onRefaaa(this)
}
myName = () =>{
alert(11111111111111)
}
render() {
return (<View></View>)
}
}