Call Component method with ref through WithTracker

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()

I think it’s better to trigger the child method by passing down data via props.
<Map centerPolyline={this.state.centerPolyline} />

and then in Map component:

componentDidUpdate() {
   if (this.props.centerPolyline) {
      this.current.centerPolyline();
   }
}