react-stripe-elements icon indicating copy to clipboard operation
react-stripe-elements copied to clipboard

this.props.stripe.elements is not a function

Open lhtdesignde opened this issue 6 years ago • 2 comments

Hi, we are just running into an error related to elements. This started happening for us yesterday. We are running the latest version 6.1.1 with react 16.13. We are pulling in stripe (https://js.stripe.com/v3/) in the head.

Screenshot 2020-04-02 at 23 25 45

It seems this.props.stripe is defined but elements() never gets created. Do you maybe have an idea why this error could happen?

lhtdesignde avatar Apr 02 '20 21:04 lhtdesignde

Hi @lhtdesignde, could you provide some information about the calling code here? What does the componentDidMount hook in StripeNewCardForm.js look like? What version of react-stripe-elements are you using?

christopher-stripe avatar Apr 02 '20 22:04 christopher-stripe

We think it was a race condition. We moved the stripe script further up to get initialized earlier. Using the latest version 6.1.1 of react-stripe-elements. componentDidMount just does const elements = this.props.stripe.elements(); where elements() function would not be defined at this point.

lhtdesignde avatar Apr 06 '20 06:04 lhtdesignde