Creating a child React component to host Stripe elements

First, we need to install the Stripe react packages. In the Terminal, we need to navigate to our gomusic project folder, then run the following command:

npm install --save react-stripe-elements

Next, let's visit the index.html file located at frontend/public/index.html. Then, right before the HTML closing tag, which is the line right before </head>, type <script src="https://js.stripe.com/v3/"></script>. This will ensure the Stripe code will be loaded when the end user loads our GoMusic application in their browser.

Now let's write some code. Inside our src folder, let's create new file called CreditCards.js. We start by importing the packages that we need for our incoming code to work: ...

Get Hands-On Full Stack Development with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.