/drum-machine

Drum machine using React for Front End Development Libraries @FreeCodeCamp

Primary LanguageJavaScript

Drum Machine - FreeCodeCamp Front End Libraries Development

Preview for Drum Machine

Table of contents

Overview

Third project of Front End Libraries Development by freeCodeCamp building Drum Machine

The challenge

Fulfill the below user stories and get all of the tests to pass. Give it your own personal style.

  1. I should be able to see an outer container with a corresponding id="drum-machine" that contains all other elements.

  2. Within #drum-machine I can see an element with a corresponding id="display".

  3. Within #drum-machine I can see 9 clickable drum pad elements, each with a class name of drum-pad, a unique id that describes the audio clip the drum pad will be set up to trigger, and an inner text that corresponds to one of the following keys on the keyboard: Q, W, E, A, S, D, Z, X, C. The drum pads MUST be in this order.

  4. Within each .drum-pad, there should be an HTML5 audio element which has a src attribute pointing to an audio clip, a class name of clip, and an id corresponding to the inner text of its parent .drum-pad (e.g. id="Q", id="W", id="E" etc.).

  5. When I click on a .drum-pad element, the audio clip contained in its child audio element should be triggered.

  6. When I press the trigger key associated with each .drum-pad, the audio clip contained in its child audio element should be triggered (e.g. pressing the Q key should trigger the drum pad which contains the string Q, pressing the W key should trigger the drum pad which contains the string W, etc.).

  7. When a .drum-pad is triggered, a string describing the associated audio clip is displayed as the inner text of the #display element (each string must be unique).

You can build your project by using this CodePen template and clicking Save to create your own pen. Or you can use this CDN link to run the tests in any environment you like: Test Script

Screenshot

Links

Live Site URL: Drum Machine

My process

Built with

What I learned

By building this Drum machine using React I learned a lot of React concepts like useState, useEffects, props, keys and list, and how to pass a state to others components.

Useful resources

  • Pass state to sibling components - This helped me for understanding how to pass state to others components. I really liked this article because this article is well explained.
  • Why do we need keys in React - This is an amazing video which helped me finally understand why we need keys in React. I'd recommend it to anyone still learning this concept.

Author

Acknowledgments

Thanks to ReactJS Indonesia Community and codingfess for helped me to answers my questions.

Development

Clone the repository, install the dependencies and start the application

git clone https://github.com/aroyan/drum-machine.git
npm install
npm start