Giter VIP home page Giter VIP logo

react_clock's Introduction

React Clock

React + Typescript cheat sheet

Create a Clock class component that will update the time every second using a given markup:

Here is the working version

  • print current time on the page on page load;
    • use .toUTCString().slice(-12, -4) methods do awoid timezone issues;
  • update the time every second using the window.setInterval;
  • start the timer only when the component is added to the page (componentDidMount).- every second print the time in the DevTools using console.info method (not the console.log);
  • make the App a class component;
  • add the hasClock property to the App state;
  • the Clock should be visible only when the hasClock is true;
  • hide the Clock on a right mouse click in the document (contextmenu event):
    document.addEventListener('contextmenu', (event) => {
      event.preventDefault(); // not to show the context menu
    
      // put your code here
    });
  • show the Clock on a left mouse click in the document (click event):
    document.addEventListener('click', () => {});
  • the time should not be printed to the console when the Clock is hidden (componentWillUnmount);
  • add the clockName having Clock-0 default value to the App state;
  • pass it to the Clock to be shown near the time (see the markup):
    <Clock name={this.state.clockName} />
  • update the clockName every 3300ms with a new value generated by existing getRandomName function;
  • each time the name is changed, the Clock must print a message with an old name and a new name using the console.debug method (use componentDidUpdate):
    Renamed from oldName to newName
    
  • to see console.debug messages enable the verbose level in DevTools console:

How to enable verbose level

check in the console that a renaming message occurs after each 3-4 time messages.

Expected console output

Instructions

  • Implement a solution following the React task guideline.
  • Use the React TypeScript cheatsheet.
  • Open one more terminal and run tests with npm test to ensure your solution is correct.
  • Replace <your_account> with your Github username in the DEMO LINK and add it to the PR description.

react_clock's People

Contributors

mgrinko avatar yuriiholiuk avatar danheim avatar vpolets avatar ibrianwarner avatar denys-cheporniuk avatar denys-danyliuk avatar solaryasha avatar alenatovstukha avatar

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.