10. Functional Programming with JavaScript
Activity 15: onCheckout Callback Prop
Solution
- Change the current directory to
Lesson10and runnpm installif you haven't done so in this directory before.npm installdownloads the dependencies that are required in order to run this activity (React and Parcel). - Run
parcel serve activity-on-checkout-prop-start.htmland then executenpm run Activity15. You will see the application starting up, as follows:Figure 10.42: Output after running the start html script
- Go to
http://localhost:1234(or whichever URL the start script output). You should see the following HTML page:Figure 10.43: Initial application in the browser
- The
onClickof the Proceed to checkout can be implemented as follows:Â Â render() { Â Â Â Â return ( Â Â Â Â Â Â <div> Â Â Â Â Â Â Â Â <p>You have {this.state.items.length} items in your basket</p> &...