React-stripe-elements: Original Component not available after wrapped in injectStripe

Created on 1 Sep 2017  路  4Comments  路  Source: stripe/react-stripe-elements

Essentially, when trying to reference a component that is wrapped by the the injectStripe HOC, I can't access any of it's. I created a codepen to illustrate the problem:

https://codepen.io/sciku1/pen/oemNEg

Is there any way to get around this? Thanks.

Most helpful comment

Thanks for the suggestion. This does currently not seem to be possible.
Can you elaborate a little on the use case why you need to be able to do this?

We can look into creating an option like injectStripe(CardForm, {withRef: true});
and then making the wrapped instance available via this.refs.cardForm.getWrappedInstance().

This should probably not be the default, because it might not work with stateless functional components.

I'll look into this!

All 4 comments

Thanks for the suggestion. This does currently not seem to be possible.
Can you elaborate a little on the use case why you need to be able to do this?

We can look into creating an option like injectStripe(CardForm, {withRef: true});
and then making the wrapped instance available via this.refs.cardForm.getWrappedInstance().

This should probably not be the default, because it might not work with stateless functional components.

I'll look into this!

This functionality was added in #75.
I'll create a new release soon.

Use case was that I wanted to have the card component be able to create a token, which could then be submitted as part of the form. Reason for this, was that I was developing a front end for a legacy system (creates card objects in the back end from tokens because it was made during V2) I did find a work around, but thank you for adding the feature! Will definitely use the library again in the future :+1:

Hey, I am not sure to understand the answers :/

So the idea is to not use inject stripe with default?

Was this page helpful?
0 / 5 - 0 ratings