#alexb_ca
1 messages · Page 1 of 1 (latest)
Yes! You can listen to ready event to find out when the element is fully rendered: https://stripe.com/docs/js/element/events/on_ready
Before the element is fully rendered, a spinner can be displayed
Thanks that looks promising.. how do I get a reference to the element to do that?
Eg in my code I'm using the react tags like <Element/>
Like you do here
Hi @deep stirrup I'm taking over this thread
btw there's a default loader that comes with stripe elements. You can turn it on by settting it to always https://stripe.com/docs/js/elements_object/create#stripe_elements-options-loader
I was hoping add my own, is there no way to get a callback when stripe elements loads?
https://stripe.com/docs/js/element/events/on_loaderstart you mean this?
No it's different. Please open the link and take a look
Well it still requires me to have a reference to element which I don't have, so that's why i asked about that
Hmm, you have difficulty in getting a element reference?
I don't know how to, I was just asking how
If you're not willing to tell me how then just say so
I'm willing to, but I need to know what you don't know.
If you are using Stripe React SDK, you can get the elements through useElements hook https://stripe.com/docs/stripe-js/react#useelements-hook
Ok well that I can do.. but I thought your link said element.on...
Not elements, so I imagined it was something else
Ah, I see
So you're saying I do: elements.on()?
That's the case if you are using Stripe.js directly
Where elements is the result of use elements
Well I'm not...
Why is why I keep asking...
If you are using react, the syntax is a bit different
Sure, let me a sec
id="payment-element"
onLoaderStart={() => {}}
...```
Something like this
Thanks, that looks like something I can try...
any docs on this? When does the callback get called? When the loader starts...?
You can refer to the same Stripe.js doc that I sent earlier.
I don't see onLoaderStart on the page
https://stripe.com/docs/js/element/events/on_loaderstart this page, the first one I sent to you.
I don't see any mention of onLoaderStart there either
I do see element.on(...)
Ok so it calls back when the loader UI is mounted? That doesn't sound like what I'm asking about at all
I was looking for a callback or way to detect when the stripe elements are fully loaded and rendered
Just to clarify, you want to listen for events that tells your when the PaymentElement is loaded, not when it starts to load? Because that's what you told me in the beginning.
I wrote: "Hi, I'm working with stripe elements, with stripe-js/react https://stripe.com/docs/stripe-js/react#setup, is there a way I can display a spinner while waiting for stripe elements to load? eg a callback or a way to detect it?"
"I was hoping add my own, is there no way to get a callback when stripe elements loads?" <- this is what you wrote
Yes which was in response to another reply from you where you said stripe had its own loader
You said there was a default loader
Anyway, I believe river has already provided the doc for the ready event, you can listen to that event to get notified.
https://stripe.com/docs/js/element/events/on_ready this is link if you need it again
Implying the default loader displays a loader while stripe elements is loading
Oh man
When he provided that answer I asked a follow up
I'd suggest you to try it out. If you face any problems, feel free to reach out again.
And you have not responded to that question
I believe river has already answered the question. Maybe I miss somthing, can you tell me which part of the answer that you don't understand?
"If you are using Stripe React SDK, you can get the elements through useElements hook https://stripe.com/docs/stripe-js/react#useelements-hook" <- this is what I wrote earlier, did you get a chance to take a look?
We discussed that already
And if you are using Stripe react library, I also share you an example on how to listen to event
id="payment-element"
onLoaderStart={() => {}}```
I'm afraid that I won't be much of help if you are always switching topics
I have no idea why you keep going on about when loading starts
I have not switched topics once
It's the exact same question I had when I started this thread
Are there no docs at all about this?
Something like
<PaymentElement onReady={() => {}}
?
Yes. You can also take a look at https://stripe.com/docs/stripe-js/react#element-components for full API reference
Thanks!
I don't understand why we had this huge conversation going all over this place. It seems like a pretty simple answer.
me either