【发布时间】:2020-01-30 20:38:50
【问题描述】:
我有一个 react-native-maps 组件嵌套了多个级别。如何从父容器访问 map.animateToRegion 函数?
class Parent extends Component{
animateToRegion = () => {
/*Need some way to call the mapview ref*/
}
return(
<Child />
)
}
class Child extends Component{
return(
<MapView ref={map => this.map = map}>
</MapView>
)
}
【问题讨论】:
-
你的
Child组件,它只是用React.forwardRef转发他们的引用
标签: react-native react-native-maps