Skip to main content

useYMaps

Return Yandex.Maps API instance

Basic Usage

const ymaps = useYMaps(modules);

Hook parameters

modules

List of modules to be loaded. For example: Map, Placemark, etc.

Here is an example of usage:

export default function App() {
const mapRef = useRef(null);
const ymaps = useYMaps(['Map']);

useEffect(() => {
if (!ymaps || !mapRef.current) {
return;
}

new ymaps.Map(mapRef.current, {
center: [55.76, 37.64],
zoom: 10,
});
}, [ymaps]);

return <div ref={mapRef} style={{ width: '320px', height: '240px' }} />;
}