Created
August 30, 2019 08:12
-
-
Save kianaditya/7c68e123ca95e88e186b7c9841c5c44e to your computer and use it in GitHub Desktop.
Lifecycle method for stripe elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentDidMount() { | |
if (window.Stripe) { | |
this.setState({stripe: window.Stripe('pk_test_12345')}); | |
} else { | |
document.querySelector('#stripe-js').addEventListener('load', () => { | |
// Create Stripe instance once Stripe.js loads | |
this.setState({stripe: window.Stripe('pk_test_12345')}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment