Skip to content

fix: ignore non-Date argument in useStopwatch reset - #145

Merged
amrlabib merged 1 commit into
amrlabib:masterfrom
SAY-5:fix-stopwatch-reset-nondate
Oct 5, 2026
Merged

amrlabib merged 1 commit into
amrlabib:masterfrom
SAY-5:fix-stopwatch-reset-nondate

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

The README shows reset being passed straight to an event handler (<button onClick={reset}>Reset</button>), but doing that passes the click event into the offset parameter. reset then hands it to Time.getMillisecondsFromExpiry, which calls .getTime() on it and throws TypeError: getTime is not a function (#142).

This guards the offset with instanceof Date so a non-Date argument is treated as no offset, matching the documented usage. Added a regression test that calls reset with an event-like object.

@amrlabib

amrlabib commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Thank you for your PR, can you please remove both lock files. the diff should contain only useStopwatch.ts and useStopwatch.test.ts

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5
SAY-5 force-pushed the fix-stopwatch-reset-nondate branch from c5e1d45 to 1eac02c Compare October 5, 2026 19:06
@SAY-5

SAY-5 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Removed both lock files, the diff is now just useStopwatch.ts and the test.

@amrlabib
amrlabib merged commit a39267d into amrlabib:master Oct 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants