File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed
src/All Assessment/assessment01 Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change 11import React , { useEffect , useState } from "react" ;
2- import ' ../../index.css'
2+ import " ../../index.css" ;
33import GoToHome from "../../Components/GoToHome" ;
44
55const StopWatch = ( ) => {
66 const [ clicked , setClicked ] = useState ( false ) ;
77 const [ time , setTime ] = useState ( 0 ) ;
88
9-
10-
119 useEffect ( ( ) => {
1210 let interval ;
1311 if ( clicked ) {
1412 interval = setInterval ( ( ) => {
15- setTime ( prevTime => prevTime + 1 ) ;
13+ setTime ( ( prevTime ) => prevTime + 1 ) ;
1614 } , 500 ) ;
1715 } else {
1816 clearInterval ( interval ) ;
@@ -24,13 +22,10 @@ const StopWatch = () => {
2422 return (
2523 < div className = "flex flex-col items-center justify-center h-screen gap-10" >
2624 < div className = "text-6xl" > { time } </ div >
27- < button
28- className = "custom-button"
29- onClick = { ( ) => setClicked ( ! clicked ) }
30- >
31- { clicked ? 'Stop' : 'Start' }
25+ < button className = "custom-button" onClick = { ( ) => setClicked ( ! clicked ) } >
26+ { clicked ? "Stop" : "Start" }
3227 </ button >
33- < GoToHome />
28+ < GoToHome />
3429 </ div >
3530 ) ;
3631} ;
You can’t perform that action at this time.
0 commit comments