I am getting the error "Uncaught IntegrationError: Can only create one Element of type card." I set the Elements provider in the root component. I read this article Only one element of type cardNumber can be created in which I think has the similar problem with mine, but we are using a little different syntax, if we are having the same problem then how can I integrate useEffect in my case?
This is my root component:
import { Elements } from '@stripe/react-stripe-js';
import { loadStripe } from '@stripe/stripe-js';
const stripePromise = loadStripe(process.env.PUBLISHABLE_KEY);
function MyApp({ Component, pageProps }) {
return (
<Elements stripe={stripePromise}>
<Component {...pageProps} />
</Elements>
);
}
export default MyApp;
This is my stripe page (where the card component is rendered).
import { CardElement } from '@stripe/react-stripe-js';
const Buy = () => {
return (
<div className={styles.container}>
<div style={{ width: ' 70%' }}>
<CardElement />
</div>
</div>
);
};
export default Buy;