import React, { useMemo } from 'react'; import { useMapTranslation } from '../locale'; import { AMapComponent } from './AMap'; import { GoogleMapsComponent } from './GoogleMaps'; const MapComponents = { amap: AMapComponent, google: GoogleMapsComponent, }; export const MapComponent = React.forwardRef((props, ref) => { const { t } = useMapTranslation(); const { mapType } = props; const Component = useMemo(() => { return MapComponents[mapType]; }, [mapType]); if (!Component) { return
{t(`The ${mapType} cannot found`)}
; } return ; });