stripe / connect-js

Loading wrapper for Connect.js
https://stripe.com/docs/connect/get-started-connect-embedded-components
MIT License
16 stars 6 forks source link

Fix the `setConnector` race condition in next.js strictmode #105

Closed jorgea-stripe closed 3 months ago

jorgea-stripe commented 3 months ago

I discovered that if we:

  1. Create an element `document.create('stripe-connect-payments');
  2. Load connect.js

Then this element does not have our custom element code loaded. The part that is missing is connecting it to the DOM.

In this case (where setConnector is not defined and the element is not connected) we simply connect and disconnect the element to the DOM to trigger the custom element code in connect.js from loading.