title: How to integrate Youtube Iframe api in reactjs solution
body: <p>In react, I am trying to create a component for custom youtube player, so that I can introduce a new player controls bar. Form youtube iframe API, it was mentioned to use following code to create a player instance, </p>
  
  <pre><code>var tag = document.createElement('script');
  
    tag.src = "https://www.youtube.com/iframe_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  
    // 3. This function creates an &lt;iframe&gt; (and YouTube player)
    //    after the API code downloads.
    var player;
    function onYouTubeIframeAPIReady() {
      player = new YT.Player('player', {
        height: '390',
        width: '640',
        videoId: 'M7lc1UVf-VE',
        events: {
          'onReady': onPlayerReady,
          'onStateChange': onPlayerStateChange
        }
      });
    }
  </code></pre>
  
  <p>But when I am trying to use this code on react component life-cycle methods (like componentDidUpdate) YT instance isn't found at all. </p>
  
  <p>Any solution to this ?</p>