Closed SCasarotto closed 4 years ago
Hi @SCasarotto,
You can use useElements
and elements.getElement
to obtain a reference to the underlying element.
import {useElements, CardElement} from '@stripe/react-stripe-js';
const PaymentForm = () => {
const elements = useElements();
const clearCard = () => {
const cardElement = elements.getElement(CardElement);
// ensure the Element is still mounted
if (cardElement) {
cardElement.clear()
}
}
// ...
}
Oh awesome my mistake. That makes sense. Sorry long day
how can we clear element value in angular
Feature request or idea? Consider opening an API review!
Summary
I would like to be able to clear the CardElement after submitting data however, it doesn't appear to be a way to get a ref. I am not seeing a way to get access to
elementRef
(previously: https://github.com/stripe/react-stripe-elements/issues/26) and it doesn't look likecreateElementComponent
forwards Ref. Am I missing something?The only method I have found to work is to change the
key
on theCardElement
component. While this works, it seems like accessing the intended properties to reset is a better solution.Other information