Closed thijssmudde closed 6 years ago
From your description it seems you're confusing the usage of React's createRef()
and callback ref, please refer to React's docs, it's not an issue with this lib.
Well, can you help understand why the methods invalidateSize() and flyToBounds nor setView are exposed?
Im following this as an example: https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/events.js
It should be possible to access these methods, right?
This worked because I had used StyledComponents which obstructed the use of ref:
<Map
ref={(ref) => this.mapRef = ref}
...
/>
centerPolyline = () => {
const {bounds} = this.state
if (bounds) {
this
.mapRef
.leafletElement
.invalidateSize()
this
.mapRef
.leafletElement
.flyToBounds(bounds)
}
}
Expected behavior
Opening and closing interface tab, should invalidate the map size and the polyline should be centered.
Actual behavior
invalidateSize and flyToBounds do not work on the ref object.
Steps to reproduce
Map component has a ref:
ref={(ref) => this.mapRef = ref}
Both methods are not available