Skip to content

[#155] Fix DeadlineCountdown hydration mismatch#163

Merged
realproject7 merged 1 commit intomainfrom
task/155-fix-deadline-hydration
Mar 16, 2026
Merged

[#155] Fix DeadlineCountdown hydration mismatch#163
realproject7 merged 1 commit intomainfrom
task/155-fix-deadline-hydration

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Always initialize remaining state as null so server and client both render --:--:-- during hydration
  • Set the calculated value only inside useEffect after mount
  • Lint rule react-hooks/set-state-in-effect suppressed with inline comment since this is the standard SSR hydration pattern

Fixes #155

Test plan

  • eslint — passes (lint rule suppressed)
  • tsc --noEmit — zero errors
  • next build — clean
  • Load a story page with deadline — no hydration mismatch error in console
  • Countdown starts after mount, placeholder --:--:-- shows briefly during SSR

🤖 Generated with Claude Code

Always initialize remaining as null so server and client both render
the placeholder during hydration. Set the value in useEffect after
mount. The lint rule is suppressed for the initial sync setState since
this is the correct SSR hydration pattern.

Fixes #155

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b APPROVE

Correct fix. The typeof window guard from PR #153 still caused a hydration mismatch because the lazy initializer computed a value on the client while the server rendered null. Unconditional null init + useEffect setState is the standard SSR pattern. Lint suppression is appropriate here — react-hooks/set-state-in-effect is a false positive for this hydration safety pattern.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

This PR fixes the remaining DeadlineCountdown hydration mismatch by making the initial render deterministic on both server and client, then starting the countdown after mount. The lint suppression is narrowly scoped, justified by the SSR requirement, and both local validation and GitHub checks pass.

Findings

  • [info] No remaining blocking findings.
    • File: src/components/DeadlineCountdown.tsx:10
    • Suggestion: None.

Decision

Approving because the change directly addresses issue #155, keeps the fix contained to one component, and passes lint-and-typecheck plus local lint, typecheck, and build validation.

@realproject7 realproject7 merged commit 4a2663f into main Mar 16, 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.

[Bug] DeadlineCountdown hydration mismatch persists

2 participants