Как в React приложении в режиме React.StrictMode заставить работать JavaScript API Яндекс Карты 3.0?
Согласно документации: Документация
Добавляю в React приложение Яндекс Карту и приложение уходит в ошибки:
Uncaught TypeError: Cannot read properties of undefined (reading 'coordinates')
Uncaught TypeError: Cannot read properties of undefined (reading 'location')
The above error occurred in the <ForwardRef> component:
и д.р.
Но когда убираю React.StrictMode приложение запускается без ошибок и яндекс карты отображаются.
import {
YMap,
YMapDefaultSchemeLayer,
YMapDefaultFeaturesLayer,
YMapMarker,
reactify
} from '../../lib/ymaps';
import type { YMapLocationRequest } from 'ymaps3';
const LOCATION: YMapLocationRequest = {
center: [37.588144, 55.733842],
zoom: 9
};
function Map() {
return (
<>
<YMap location={reactify.useDefault(LOCATION)}>
<YMapDefaultSchemeLayer />
<YMapDefaultFeaturesLayer />
<YMapMarker
coordinates={reactify.useDefault([37.588144, 55.733842])}
draggable={true}
>
<section>
<h1>You can drag this header</h1>
</section>
</YMapMarker>
</YMap>
</>
);
}
export default Map;