Giter Club home page Giter Club logo

react-stopwatch's Introduction

React Stopwatch

Recreate a stopwatch in React. Your final product should function similarly to this deployed version of the component.

Getting Started

  • Fork and clone this repo
  • Once you have the app locally, install necessary dependencies with $ npm install
  • Start the development server locally with $ npm start, then visit localhost:3000 in the browser to view app

Instructions

Take the existing markup rendered from the Stopwatch component in src/Stopwatch.js and change into a fully functioning component. This means that you only have to add functionality -- not markup or styling -- to the existing code!

Steps to Take

  1. Add a constructor method and initialize state with a counter property to track the incrementing time. (You may need additional state properties later on)

  2. Create a handleStart method that calls setInterval() and updates counter every second. (Make sure to use setState to update)

  3. Include an onClick attribute on the start button which calls handleStart

  4. Replace the 0 in the h1 heading with your counter.

  5. Next you will need to create onClick event attributes for reset and pause and associated methods for each.

Hints...Shhhhhh!

You will also most likely need to include an additional attribute in your constructor method that keeps track of your current interval. If you have an active interval, then don't let the start button be fired again!

You can use clearInterval to stop the current interval!

Bonus!

  • When the stopwatch is at 0, the display time should be a different style.
  • When the user first visits the page, the only button that should be active is "Start".
    • The other buttons should be unlocked only after the user clicks "start"
  • Have multiple Stopwatch components rendered on the page so the User can set off multiple timers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.