Skip to content

fix: resolve react-hooks/set-state-in-effect lint error in GameProvider - #29

Merged
martinl5 merged 1 commit into
mainfrom
claude/gameprovideer-setstate-effect-pyozon
Jul 14, 2026
Merged

fix: resolve react-hooks/set-state-in-effect lint error in GameProvider#29
martinl5 merged 1 commit into
mainfrom
claude/gameprovideer-setstate-effect-pyozon

Conversation

@martinl5

Copy link
Copy Markdown
Owner

Summary

CI lint was failing on src/components/GameProvider.tsx with a react-hooks/set-state-in-effect error: the rank-promotion detector called setPromotionRank synchronously inside a useEffect, which can trigger cascading renders.

This replaces the prevRankRef + useEffect combination with the render-phase state-adjustment pattern recommended by the React docs (You Might Not Need an Effect): the previous rank is tracked in state, and when it differs from the current rank during render, the promotion banner state is updated immediately — no effect, no extra committed render of stale UI.

Behavior is unchanged: the banner still doesn't fire on the initial render (previous rank starts as null), and fires whenever the rank name changes afterwards.

Verification

  • npm run lint — passes (exit 0)
  • npx tsc --noEmit — passes (exit 0)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Dsq9LChvMw1JVyhQj9roav


Generated by Claude Code

Replaces the prevRankRef + useEffect promotion detector with the
render-phase state-adjustment pattern recommended by the React docs,
resolving the react-hooks/set-state-in-effect lint error.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dsq9LChvMw1JVyhQj9roav
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sqlwak Ready Ready Preview, Comment Jul 14, 2026 10:00am

@martinl5
martinl5 marked this pull request as ready for review July 14, 2026 10:01
@martinl5
martinl5 merged commit 57c0d24 into main Jul 14, 2026
3 checks passed
@martinl5
martinl5 deleted the claude/gameprovideer-setstate-effect-pyozon branch July 14, 2026 10:01
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.

2 participants