Skip to content

please add a new stopwatch component. #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/components/ui/Stopwatch/Stopwatch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// src/components/ui/Stopwatch/Stopwatch.tsx

import { useEffect, useState } from 'react';

const Stopwatch = () => {
const [seconds, setSeconds] = useState(0);

useEffect(() => {
const interval = setInterval(() => {
setSeconds(seconds => seconds + 1);
}, 1000);

return () => clearInterval(interval);
}, []);

return (
<div>
Seconds: {seconds}
</div>
);
};

export default Stopwatch;
3 changes: 3 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { type AppType } from "next/app";
import ThemeProvider from "@components/ui/Theme/ThemeProvider";
import Stopwatch from "@components/ui/Stopwatch/Stopwatch"; // New import
import "../styles/globals.css";
import { QueryClient, QueryClientProvider } from "react-query";
import { v4 as uuid } from "uuid";
Expand All @@ -17,10 +18,12 @@ const MyApp: AppType = ({ Component, pageProps: { ...pageProps } }) => {
// Provide the client to your App
<ThemeProvider>
<QueryClientProvider client={queryClient}>
<Stopwatch /> {/* New utilization */}
<Component {...pageProps} />
</QueryClientProvider>
</ThemeProvider>
);
};

export default MyApp;