This is link for codesandbox. I think there is someother way we can make this work. I was not able to figure out that. The same worked with react-leaflet v2.8.0. Can someone help me out with this.
TypeErrorCannot read properties of undefined (reading 'fitBounds')
mapRef.current.leafletElement.fitBounds()