Optimize add-provider dialog state derivation#2602
Draft
cursor[bot] wants to merge 2 commits intomainfrom
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
useEffectchain.docs/perf-recordings/add-provider-dialog-before-react-scan.webmdocs/perf-recordings/add-provider-dialog-after-react-scan.webmWhy
React Doctor flagged
AddProviderInstanceDialogfor both cascading state updates in an effect and an effect chain derived fromdriver/label. This change follows React's "You Might Not Need an Effect" guidance by replacing derived state synchronization with render-time derivation and state ownership scoped to the open dialog content.React Doctor result improved from 68/100 to 69/100, reducing total findings from 763 to 760 and state/effects findings from 28 to 26. The add-provider dialog no longer appears in
react-doctor/no-effect-chainorreact-doctor/no-cascading-set-state.UI Changes
No intended visual UI changes. Interaction recordings with react-scan enabled are included in this PR:
docs/perf-recordings/add-provider-dialog-before-react-scan.webmdocs/perf-recordings/add-provider-dialog-after-react-scan.webmChecklist
Verification:
bun fmtbun lint(passes with existing warnings)bun typecheckbunx react-doctor@latest apps/web --verbose --offline --fail-on noneNote
Optimize state derivation in
AddProviderInstanceDialogby removinguseEffectresetsAddProviderInstanceDialogContentchild component that only mounts when the dialog is open, replacinguseEffect-driven form resets with natural unmount/remount behavior.instanceId/instanceIdDirtystate pair and its twouseEffecthooks with a singlemanualInstanceIdstate and a derivedinstanceIdcomputed asmanualInstanceId ?? deriveInstanceId(driver, label).docs/perf-recordings/.Macroscope summarized f991605.