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

setApi fired when ymaps is not ready yet #312

Open
ValeryVS opened this issue Jul 19, 2021 · 2 comments
Open

setApi fired when ymaps is not ready yet #312

ValeryVS opened this issue Jul 19, 2021 · 2 comments

Comments

@ValeryVS
Copy link

react-yandex-maps 4.4.0

I use YMaps provider in such way

      <YMaps
        query={{
          ns: 'ymaps',
          load: ['package.full', 'overlay.Polygon'].join(','),
          apikey: process.env.REACT_APP_YMAPS_KEY,
          coordorder: 'longlat',
        }}
      >

with ns: 'ymaps', because it's necessary for vector maps.

Strangely, in lates build of my app, this line
https://github.com/gribnoysup/react-yandex-maps/blob/master/src/YMaps.js#L41
sometimes fired before this line
https://github.com/gribnoysup/react-yandex-maps/blob/master/src/YMaps.js#L79
but ymaps isn't ready at that point.
It has only load, modules, ready, vow and __provideBundle.
Then ymaps object is provided by Map component render nothing. My custom components with withYmaps HOC also receives uncompleted ymaps object and crush.

@ValeryVS
Copy link
Author

ValeryVS commented Jul 19, 2021

It seems, that my app rerenders App component frequently in current build. Which triggers load function from YMaps provider. getPromise function works correct and maps loads only one time. But sometimes load function fired when window.ymaps is in incompleted state.

In that case

  • provider get ymaps in incompleted state
  • setApi fired again from ymaps.ready callback, but some components are already crushed, including Map component from react-yandex-maps.

@ValeryVS
Copy link
Author

Also, may be I misused withYmaps HOC.
What exactly second argument waitForApi for? Is it possible to get unready ymaps if waitForApi leaved by default, which is false?

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

1 participant