Giter VIP home page Giter VIP logo

Comments (5)

gribnoysup avatar gribnoysup commented on June 18, 2024

Привет, маленькое демо с репродукцией ошибки очень помогло бы понять в чем может быть причина

from react-yandex-maps.

xfishernet avatar xfishernet commented on June 18, 2024

https://codesandbox.io/s/21145v40z0

сначала переходим на ссылку /map

потом кликаем на TEST ссылку

я конечно могу в событии сделать проверку if (!map) return; там где ошибка, но хотелось бы узнать, почему именно то событие выполняется, когда перехожу по ссылке.

from react-yandex-maps.

mmarkelov avatar mmarkelov commented on June 18, 2024

@xfishernet react-yandex-maps will call the instanceRef callback with the YandexMap Object instance when the component mounts, and call it with null when it unmounts.
Тут конечно @gribnoysup подробнее пояснит. Но просто надо делать доп проверки на существование
https://codesandbox.io/s/34lr1w48r1

from react-yandex-maps.

gribnoysup avatar gribnoysup commented on June 18, 2024

@xfishernet как правильно заметил @mmarkelov происходит это потому что instanceRef коллбэк будет вызван c аргументом null, когда React вызывает коллбэк componentWillUnmount. Это поведение повторяет поведение callback refs в React:

React will call the ref callback with the DOM element when the component mounts, and call it with null when it unmounts.

https://reactjs.org/docs/refs-and-the-dom.html#callback-refs

Я закрою issue, но если у тебя остались вопросы, спрашивай

from react-yandex-maps.

MaGaKZ avatar MaGaKZ commented on June 18, 2024

Хочу выразить огромную благодарность вам. Но я хотел спосить об одной ошибке которая выходит у меня:

Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method. in YandexMapWrap

Я пробывал исправить это так:

class YandexMapWrap extends React.Component {
  _isMounted = false;
  componentDidMount() {
    this._isMounted = true;
  }

  componentWillUnmount() {
    this._isMounted = false;
  }
}

и каждый раз проверяю на это когда вызываю this.setState() но похожо что это не помогает.
Не могли вы подсказать почему так выходит и как исправить это ?

Thanks in advance!

from react-yandex-maps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.