Create a component that implements a stop timer, allowing users to start, stop, and reset the timer.
MediumProblem Statement
Create a component that implements a stop timer, allowing users to start, stop, and reset the timer.
Sample Input
Initial time: 0
Sample Output
A timer that counts up when started, pauses when stopped, and resets to 0.
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
import React, { useState, useEffect } from "react";
const Timer = () => {
return (
<div>
<p>Time: 0</p>
<button>Start</button>
<button>Stop</button>
<button>Reset</button>
</div>
);
};
export default Timer;
Input
Initial time: 0
Expected Output
A timer that counts up when started, pauses when stopped, and resets to 0.