#Hero
1 messages · Page 1 of 1 (latest)
Hi there, how do you render the PaymentElement in you webpage?
using a react component like this:
<div>
<div style={{width:400, backgroundColor:'white', padding: 20, borderRadius: 10}}>
<PaymentElement id={'payment-element'} />
<PayButton onClick={handlePay}>
{isLoading ? <div className={'spinner'} id={'spinner'}></div> : 'Pay now'}
</PayButton>
</div>
</div>
OK, and how do you render <Elements> ?
<Elements stripe={stripePromise} options={{clientSecret:payment.secret, appearance}}>
<CheckoutForm clientSecret={payment.secret}/>
</Elements>
OK, and I guess you do a conditionally rendering to show <Elements> only when clientSecret is set right?
OK. The code looks fine. Does your page include any 3rd-party css or library that could affect animations?
Remove any other 3rd-party css and js library and see if the animation is smooth.
so what is the correct animation for it to show? starting with height 0 and then just growing vertically until is fully shown?
You don't need to set any animation for PaymentElement.
i mean the default way
how is supposed to look like when it appears?
do you have an example i can look at to see how it appears properly
okay, looking at the CSS on that page it seems like the container has a min-height of 500px
and the stripe element is centered
so it doesnt make the container grow or shrink
You can see the container grow or shrink by clicking Klarna and then Card
yea when it grows over 500px
but still has that limit so it doesnt shrink to 0 at the start
seems like adding that min height prevents the popping now
thanks for the help
one last question, is there any variable in the element that shows when all the inputs are valid, so we can enable the "Pay now" button
https://stripe.com/docs/js/element/events/on_change?type=paymentElement#element_on_change-handler-complete yes you can listen to the change events and check if event.complete = true
and this 'paymentElement', do I get it using useRef?
You can pass the onChangeListener through its options