Skip to content

[Bug] Writer tab: useState(checkExpired) causes SSR hydration mismatch #835

@realproject7

Description

@realproject7

Problem

PR #834 uses useState(checkExpired) as a lazy initializer, which calls Date.now() during the initial render. Server and client timestamps differ, causing a potential React hydration mismatch warning for storylines near the expiry boundary.

Also: the 1-second setInterval polling is wasteful for a badge that only transitions once (active → expired). A setTimeout targeting the exact expiry time would be more efficient.

Solution

  1. Change useState(checkExpired) to useState(false) — let the existing useEffect set the correct value on mount
  2. Replace setInterval(1000) with setTimeout calculated from expiryTime - Date.now()

Acceptance Criteria

  • No SSR hydration mismatch warnings
  • Badge still correctly shows expired/active/complete
  • No 1-second polling — use targeted setTimeout instead
  • Cleanup timeout on unmount

Branch

task/<issue>-badge-hydration-fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/T3Assigned to T3 builder agentbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions