Skip to content
Discussion options

You must be logged in to vote

To fix the clock:
1. Open src/components/Taskbar.js.
2. Ensure the clock uses a setInterval hook for real-time updates:
javascript<br>import { useState, useEffect } from 'react';<br>const Taskbar = () => {<br> const [time, setTime] = useState(new Date().toLocaleTimeString());<br> useEffect(() => {<br> const timer = setInterval(() => setTime(new Date().toLocaleTimeString()), 1000);<br> return () => clearInterval(timer);<br> }, []);<br> return <div>{time}</div>;<br>};<br>
3. Test with npm run dev.
4. Check for memory leaks by ensuring clearInterval runs on unmount.
5. Submit a pull request.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by IsmailBinMujeeb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed question Further information is requested
2 participants