Back to results
mate-academy/react_clock(opens in a new tab)
Language: JavaScript
- stars
- 7
- watchers
- 8
- forks
- 2,868
- open issues
- 2,761
- Last updated
- 09/11/2024
Language: JavaScript
Create a Clock class component that will update the time every second using a given markup:
Here is the working version
.toUTCString().slice(-12, -4) methods do avoid timezone issues;window.setInterval;componentDidMount);console.log method;console.log of console.warn command to ignore linter error
// eslint-disable-next-line no-console console.log('some message');
App a class component;hasClock property to the App state;Clock should be visible only when the hasClock is true;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 });
Clock on a left mouse click in the document (click event):
document.addEventListener('click', () => {});
componentWillUnmount);clockName having Clock-0 default value to the App state;Clock to be shown near the time (see the markup):
<Clock name={this.state.clockName} />
clockName every 3300ms with a new value generated by existing getRandomName function;Clock must print a message with an old name and a new name using the console.warn method (use componentDidUpdate):
Renamed from oldName to newName
check in the console that a renaming message occurs after each 3-4 time messages.
npm test to ensure your solution is correct.<your_account> with your Github username in the DEMO LINK and add it to the PR description.