Skip to content

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

Open
SAY-5 wants to merge 1 commit into
amrlabib:masterfrom
SAY-5:fix-stopwatch-reset-nondate
Open

SAY-5 wants to merge 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

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.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>

This branch has not been deployed

No deployments
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.

1 participant