GithubHelp home page GithubHelp 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 avoid 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.log method;
  • add the next comment above the console.debug line to ignore linter error
    // eslint-disable-next-line no-console
    console.log('some message');
  • 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: MouseEvent) => {
      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

  • Install Prettier Extention and use this VSCode settings to enable format on save.
  • 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

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

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react_clock's Issues

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.