Try to use markerGroupRef.current
as effect hook dependency.
useEffect(() => {
if(markerGroupRef.current) {
//here I want to access a method called getBounds() which is in the markerGroupRef.current object
//but markerGroupRef.current has null value and so it doesn't execute
//when making a save change and react app reloads it has the FeatureGroup class as value as expected
console.log(markerGroupRef.current)
}
}, [markerGroupRef.current])