Closed baptisteArno closed 2 years ago
As a workaround, I inject the script programmatically using this function with the frame document as a param:
export const initStripe = (document: Document): Promise<void> =>
new Promise((resolve) => {
const existingScript = document.getElementById('stripe-script')
if (existingScript) return resolve()
const script = document.createElement('script')
script.src = 'https://js.stripe.com/v3'
script.id = 'stripe-script'
document.body.appendChild(script)
script.onload = () => {
resolve()
}
})
Yeah scripts don't execute when injected via react/innerHTML your solution is the only way around it. You can also just hook into the contentDidMount
callback and inject it then too.
I'm having this issue: https://github.com/stripe-archive/react-stripe-elements/issues/134#issuecomment-359123436
So I'm currently trying to add the Stripe script tag into the iframe
head
:But then whenever I look for the
Stripe
global var on iframe's window it doesn't exist: