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

Original Component not available after wrapped in injectStripe

Open sciku1 opened this issue 9 years ago • 4 comments

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.

sciku1 avatar Aug 31 '17 22:08 sciku1

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!

cweiss-stripe avatar Sep 05 '17 14:09 cweiss-stripe

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

cweiss-stripe avatar Sep 13 '17 01:09 cweiss-stripe

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:

sciku1 avatar Sep 13 '17 17:09 sciku1

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

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

Emixam23 avatar Feb 18 '18 17:02 Emixam23