Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Yandex maps are rendered twice React18 StrictMode #333

Open
Kaptoiiika opened this issue Apr 18, 2022 · 7 comments
Open

Yandex maps are rendered twice React18 StrictMode #333

Kaptoiiika opened this issue Apr 18, 2022 · 7 comments

Comments

@Kaptoiiika
Copy link

Kaptoiiika commented Apr 18, 2022

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
image

If i comment React.StrictMode

//<React.StrictMode>
    <YMaps>
      <Map defaultState={maState}></Map>
    </YMaps>
//</React.StrictMode>

i will get a normal work
image

@StrongerMyself
Copy link

Такая же проблема

@StrongerMyself
Copy link

Также в моем случае интерактивным остается именно вторая карта, на первой не ставятся точки, только меняется масштаб и зум

@StrongerMyself
Copy link

StrongerMyself commented Apr 27, 2022

Пока грязным хаком спрятал первый

ymaps[class$="map"]:first-child:not(:last-child) {
    display: none;
}

@proweb
Copy link

proweb commented Apr 27, 2022

+1

1 similar comment
@kaptn3
Copy link

kaptn3 commented May 13, 2022

+1

@bartwork
Copy link

https://stackoverflow.com/questions/61254372/my-react-component-is-rendering-twice-because-of-strict-mode

@Loori-R
Copy link

Loori-R commented May 24, 2022

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants