Hi and thanks for checking this post out.
I did the 25 + 5 clock front end libraries project a few years ago and didn’t feel that good about it. For one, I wasn’t that comfortable with React at the time, but also I was in a hurry to move on. Recently, I’ve seen some people trying to tackle this challenge using React Hooks and having a rough go of it. Recalling that I did the challenge using class components, I decided to take an afternoon and redo the challenge using Hooks.
I’m interested in any feedback regarding the use of Hooks here, and in general effectively managing state while optimizing use of hooks in the context of the component lifecycle.
I have to give credit to Dan Abramov at React for writing such a helpful blog post concerning the
setInterval API and using it in a React component.
The live working app is hosted at Netlify:
Live Working Demo
The code is at GitHub:
Project Code Repository
The test suite has been included so you can run all the tests to verify that everything’s working. All tests should pass on your PC browser, but the audio tests will fail on iPhones since it seems iOS will block the audio from playing as a policy. I’m not sure about Androids, but I’m guessing the result will be the same.
Thanks in advance!