Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reconfigureOnUpdate prop. Reconfigure whenever stripeKey changes. #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

michaeljonsampson
Copy link

@michaeljonsampson michaeljonsampson commented Jun 6, 2018

This removes the need for reconfigureOnUpdate. It didn't work right. It would cause stripe to update too often and wasn't necessary. Now we just watch for stripeKey to change. I've been using this code in production for a few months.

resolve #103

componentDidUpdate() {
if (!scriptLoading) {
componentDidUpdate(prevProps) {
if (!scriptLoading && this.props.stripeKey !== prevProps.stripeKey) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the wrong comparison to make. The stripeHandler is a static member of ReactStripeCheckout, so it may have been set by a completely different instance of the component.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you are saying about multiple instances of the component.

All I'm doing here is replacing the reconfigureOnUpdate option with a prop check that checks for the only prop that matters for reconfiguring.

As currently written it doesn't appear that this component will work with multiple instances of the component each with their own stripe key and this PR isn't attempting to fix that.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. That's why I put together #116 based on your work, which does allow for proper support for multiple instances with different Stripe keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple stripe accounts
2 participants