A
A
Anton2015-12-10 17:29:00
React
Anton, 2015-12-10 17:29:00

Yandex maps, webpack and react?

Tell me how to properly connect Yandex maps to the react component?
I use this template
https://github.com/iam4x/isomorphic-flux-boilerplate

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nash, 2016-10-27
@SPAHI4

For everyone who came here from a search, I advise you to use
https://github.com/effrenus/yandex-map-react

A
Anton, 2016-02-19
@SPAHI4

Who needs it, I did this:
thanks for the code https://bradb.net/blog/promise-based-js-script-loader/

function script(url) {
  if (Array.isArray(url)) {
    let self = this;
    let prom = [];
    url.forEach(function (item) {
      prom.push(self.script(item));
    });
    return Promise.all(prom);
  }

  return new Promise(function (resolve, reject) {
    let r = false;
    let t = document.getElementsByTagName('script')[0];
    let s = document.createElement('script');

    s.type = 'text/javascript';
    s.src = url;
    s.async = true;
    s.onload = s.onreadystatechange = function () {
      if (!r && (!this.readyState || this.readyState === 'complete')) {
        r = true;
        resolve(this);
      }
    };
    s.onerror = s.onabort = reject;
    t.parentNode.insertBefore(s, t);
  });
}

script('//api-maps.yandex.ru/2.1/?lang=ru_RU').then(() => {
      const ymaps = global.ymaps;
    });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question