perf(render): read whole-state actions from currentStateRef - #406
perf(render): read whole-state actions from currentStateRef#406NesiciCoding wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 53 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
connectDatabase, pushAllToDatabase, pullFromDatabase and dismissMigrationPrompt were useCallbacks with a [state] dep, so ANY dispatch re-created them, which re-created the platform context value and re-rendered every platform consumer (landing, migration prompt, db-sync UI, admin pages). They now read currentStateRef.current (already kept in sync by an effect for the reconnect handler) with [] deps, so their identity is stable across dispatches. The platform value now only changes on genuine session changes (landingState, showMigrationPrompt, microsoftUser). Verified: tsc clean, ESLint 0 errors, full suite 210 files pass, and the AppContext isolation test now proves a saveStudentRubric dispatch adds zero platform-consumer renders and keeps the action identities constant (the test fails without this change). Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
a741fe9 to
57e5e6a
Compare
a580cd7 to
ed621a0
Compare
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Third link in the stacked chain: #403 (domain split) → #405 (roster split) → this (state-ref reads). Stacked on
perf/roster-subdomain-split; the diff is exactly this commit.What changed
connectDatabase,pushAllToDatabase,pullFromDatabaseanddismissMigrationPromptwereuseCallbacks with a[state]dep — so any dispatch re-created them, re-creating the platform context value and re-rendering every platform consumer (landing page, migration prompt, db-sync UI, admin pages).They now read
currentStateRef.current(a ref the provider already kept in sync via an effect for the reconnect handler) with[]deps. Their identity is now stable across dispatches; the platform value only changes on genuine session changes (landingState,showMigrationPrompt,microsoftUser). This closes the last remaining "re-renders on every dispatch" leak from the domain-split audit.Verification
tsc --noEmitclean, ESLint 0 errorssaveStudentRubricdispatch adds zero platform-consumer renders and keeps the three action identities constant — verified the test fails without this change (3 extra platform renders on the dispatch)