title: ChargeBee Drop-in checkout + React: Error
body: <p>I'm trying to add the drop-in checkout to a react SPA, following <a href="https://www.chargebee.com/checkout-portal-docs/drop-in-tutorial.html#implementation" rel="nofollow noreferrer">https://www.chargebee.com/checkout-portal-docs/drop-in-tutorial.html#implementation</a>. I'm dynamically adding <code>chargebee.js</code> after the rest of the view gets rendered, and then call <code>registerAgain()</code>.</p>
  
  <pre><code>componentDidMount() {
      const el = document.createElement('script');
      el.onload = () =&gt; {
          window.Chargebee.registerAgain();
          // this.setState({ chargebeeReady: true });
      };
      el.setAttribute('data-cb-site', 'derp-test');
      el.setAttribute('src', 'https://js.chargebee.com/v2/chargebee.js');
      document.body.appendChild(el);
  }
  
  render() {
      // [...]
      &lt;a
          href="javascript:void(0)"
          data-cb-type="checkout"
          data-cb-plan-id="asdf-test"
      &gt;
          Subscribe
      &lt;/a&gt;
      // [...]
  }
  </code></pre>
  
  <p>when clicking <code>subscribe</code> I get an error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'getCart' of null
      at t.a (event-binding.ts:24)
      at Function.value (chargebee.ts:46)
      at HTMLScriptElement.el.onload (Subscribe.js:23)
  </code></pre>