stripe-archive/react-stripe-elements

this.props.stripe.elements is not a function

Closed this issue · 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?

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?

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.