Related to this issue Get component method via 'refs' from react-meteor-data constructor on which no good answer was provided
The question is simple. How to call a child component’s function from the parent, while the child component is wrapped in a WithTracker.
Example code:
Inside a Leaflet Map: The child
centerPolyline = () => {
const {bounds} = this.state
if (bounds) {
this
.mapRef
.leafletElement
.invalidateSize()
this
.mapRef
.leafletElement
.flyToBounds(bounds)
}
}
Inside Parent component
<Map
ref={(ref) => this.mapRef = ref}/>
and calling like
this
.mapRef
.current
.centerPolyline()