diff --git a/src/App.tsx b/src/App.tsx
index 3003738..7840899 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,10 +1,8 @@
-import { useCountUp } from "./hooks";
+import { useStopwatch } from "./hooks";
const App = () => {
const { current, isPaused, isOver, pause, play, reset, togglePause } =
- useCountUp(1, 10, {
- onFinish: () => console.log("Counter ended"),
- });
+ useStopwatch();
return (
diff --git a/src/helpers/useInternalStopwatch.ts b/src/helpers/useInternalStopwatch.ts
index 16cbcf7..97dd01a 100644
--- a/src/helpers/useInternalStopwatch.ts
+++ b/src/helpers/useInternalStopwatch.ts
@@ -5,7 +5,7 @@ import { InternalCounter, StopwatchOptions } from "../interfaces";
export const useInternalStopwatch = (
options: StopwatchOptions
): InternalCounter => {
- const { startPaused, separator, onFinish, endTime } = options;
+ const { startPaused, separator, onFinish, endTime, onPause } = options;
const { days, hours, minutes, seconds } = parseTime(endTime ?? "0:0:0:0");
const [time, setTime] = useState({
days: 0,
@@ -96,7 +96,10 @@ export const useInternalStopwatch = (
time.minutes * 60 +
time.seconds)
: 0,
- pause: () => setPaused(true),
+ pause: () => {
+ setPaused(true);
+ onPause && onPause();
+ },
play: () => setPaused(false),
reset: () => {
setIsOver(false);
diff --git a/src/interfaces/interfaces.ts b/src/interfaces/interfaces.ts
index 1314424..61bdbc1 100644
--- a/src/interfaces/interfaces.ts
+++ b/src/interfaces/interfaces.ts
@@ -6,6 +6,7 @@ export interface BaseCounterOptions {
export interface TimerOptions extends BaseCounterOptions {
separator?: string;
+ onPause?: () => void;
}
export interface StopwatchOptions extends TimerOptions {