title: Integrate sharethis in ReactJS
body: <p>I need to integrate sharethis in my reactjs application. I need that script to execute only in one component. Currently this is how I have implemented.</p>
  
  <pre><code> componentWillMount() {
   const script = document.createElement("script");
   script.src ="//platform-api.sharethis.com/js/sharethis.js#property=242434664&amp;product=sop?r=" +new Date().getTime();
   script.async = true;
   script.id = "shareThisId";
   document.body.appendChild(script);
  }
  </code></pre>
  
  <p>The problem with this is since this component is mounted through react routing and  page reload doesn't happen, the script doesn't re-execute.</p>
  
  <p>I tried removing the script tag on componentWillUnmount lifecycle by using removeChild, but that still doesn't re-execute the script on mounting and I learnt that it happens because of this - <strong>The removed child node still exists in memory</strong> according to <a href="https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild</a>.</p>
  
  <p>Also, the script needs to re-execute on mount so that I get updated share count each time.</p>