Skip to content

feat(countdown-timer): add onExpire callback to match sibling (FlowwStar/FlowStar#384) - #389

Open
jdjioe5-cpu wants to merge 1 commit into
FlowwStar:mainfrom
jdjioe5-cpu:feat/issue-384-add-onexpire
Open

feat(countdown-timer): add onExpire callback to match sibling (FlowwStar/FlowStar#384)#389
jdjioe5-cpu wants to merge 1 commit into
FlowwStar:mainfrom
jdjioe5-cpu:feat/issue-384-add-onexpire

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

Summary

Closes #384.

Change

components/ui/countdown-timer.tsx:

  • Add onExpire?: () => void to CountdownTimerProps.
  • Fire it exactly once per active→expired transition via a useRef flag
    (firedRef). Re-arm when the timer transitions back to active.
  • No change to the rendered markup or to formatTimeRemaining /
    useNow behaviour.

Why this shape

  • Matches AccessibleCountdownTimer's onStateChange callback pattern but
    filtered to the one transition (active → expired) that an anonymous
    countdown consumer actually wants — keeps the public API of the simpler
    CountdownTimer lean.
  • A future migrate-to-fully-consistent refactor can lift onStateChange
    in later without breaking the new onExpire shape.

…lowwStar#384)

Closes FlowwStar#384.

Adds an optional `onExpire` callback prop to CountdownTimer, keeping its
API consistent with AccessibleCountdownTimer. Implementation uses a useRef
flag (firedRef) to guarantee exactly-one invocation per active->expired
transition even across re-renders or target mutations.

- Adds `onExpire?: () => void` to CountdownTimerProps
- Re-arms firedRef when target transitions back to active
- Same prop ordering / typing shape as AccessibleCountdownTimer's
  onStateChange, so a future migrate-to-consistency refactor is mechanical.
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.

good first issue: add onExpire callback to CountdownTimer to match its AccessibleCountdownTimer sibling

1 participant