react-yandex-maps
react-yandex-maps copied to clipboard
Yandex maps are rendered twice React18 StrictMode
React 18 index.tsx
import React from 'react'
import ReactDOM from 'react-dom/client'
import { Map, YMaps } from 'react-yandex-maps'
const maState = {
center: [55.751574, 37.573856],
zoom: 5,
}
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
root.render(
<React.StrictMode>
<YMaps>
<Map defaultState={maState}></Map>
</YMaps>
</React.StrictMode>
)
Preview
If i comment React.StrictMode
//<React.StrictMode>
<YMaps>
<Map defaultState={maState}></Map>
</YMaps>
//</React.StrictMode>
i will get a normal work
Такая же проблема
Также в моем случае интерактивным остается именно вторая карта, на первой не ставятся точки, только меняется масштаб и зум
Пока грязным хаком спрятал первый
ymaps[class$="map"]:first-child:not(:last-child) {
display: none;
}
+1
+1
https://stackoverflow.com/questions/61254372/my-react-component-is-rendering-twice-because-of-strict-mode
+1