Skip to content

docs: wrap reset handler in useStopwatch example - #147

Open
OFK0 wants to merge 1 commit into
amrlabib:masterfrom
OFK0:fix/142-reset-event-argument
Open

docs: wrap reset handler in useStopwatch example#147
OFK0 wants to merge 1 commit into
amrlabib:masterfrom
OFK0:fix/142-reset-event-argument

Conversation

@OFK0

@OFK0 OFK0 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Closes #142

Problem

The README documents passing reset straight to an event handler:

<button onClick={reset}>Reset</button>

Doing that throws at runtime:
TypeError: e2.getTime is not a function at getMillisecondsFromExpiry

React invokes click handlers with the MouseEvent as the first argument, and reset only checked that its offset parameter was truthy before handing it to Time.getMillisecondsFromExpiry, which calls expiry?.getTime(). A MouseEvent is truthy and has no getTime, so it blows up.

The repo's own demo already worked around this with onClick={() => reset()}, so the README was teaching a pattern the library could not support.

Fix

Update the README stopwatch example to onClick={() => reset()}, matching the demo app.

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.

useStopwatch: onClick={reset} throws TypeError: getTime is not a function

1 participant