Skip to content

Instantly share code, notes, and snippets.

@ryanbelke
Created October 13, 2018 19:05
Show Gist options
  • Select an option

  • Save ryanbelke/2df4d4d4827a8866cfa2d879c8a5bdca to your computer and use it in GitHub Desktop.

Select an option

Save ryanbelke/2df4d4d4827a8866cfa2d879c8a5bdca to your computer and use it in GitHub Desktop.
class App extends React.Component {
constructor() {
super();
this.state = {stripe: null};
}
componentDidMount() {
// Create Stripe instance in componentDidMount
// (componentDidMount only fires in browser/DOM environment)
this.setState({stripe: window.Stripe('pk_test_12345')});
}
render() {
return (
<StripeProvider stripe={this.state.stripe}>
<Elements>
<InjectedCheckoutForm />
</Elements>
</StripeProvider>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment