#keelzebub_code

1 messages · Page 1 of 1 (latest)

subtle rockBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1351302290702598154

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

subtle nest
#

Hi there

dark island
#

Hello!

subtle nest
#

I think you can just use:
const { error, confirmationToken } = await stripePromise.createConfirmationToken({
elements,
});

dark island
#

Sorry, my code might not be clear— elements is undefined in that example above; I don't know how to create a reference to the <Elements> component in the same component in which I'm using it

#

For example, I was thinking about doing:

      elements: elementsRef.current, 
    });```

And adding a ref to the component itself (`<Elements ref={elementsRef} />`), but that didn't seem to work
subtle nest
dark island
#

I have—in that example, the <Elements /> component is in a parent component, with the call to stripe.createConfirmationToken in the child component.

I could potentially just create an extra wrapper parent component in which I instantiate <Elements>, I was just wondering if there's a way to avoid that and have both <Elements> and stripe.createConfirmationToken in the same component

subtle nest
#

Give me a few minutes to loop in a teammate

frigid current
#

Hi there! Let me take a look here and do some quick testing

frigid current
#

The short answer is that you can't do this while using our React components; the components need to be rendered inside a component that is wrapped in the Elements provider. We discuss this, though not in great detail, in our documentation here: https://docs.stripe.com/sdks/stripejs-react#elements-provider

dark island
#

Gotcha, thank you for your help!