Remove derived state effects from provider dialog#2698
Draft
cursor[bot] wants to merge 2 commits into
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
useEffectreset path by remounting the form content when the dialog open state changes.useEffectfor instance IDs; the ID is now derived during render until the user manually edits it.artifacts/react-scan/add-provider-dialog-before.webmartifacts/react-scan/add-provider-dialog-after.webmWhy
React Doctor flagged
AddProviderInstanceDialogfor an effect chain and cascading state updates. The previous label/driver flow rendered once for the label/driver update, then rendered again when an effect wrote the derived instance ID. Deriving the ID during render follows React guidance for avoiding unnecessary effects and removes that extra commit path.Post-fix React Doctor no longer reports
no-effect-chain,no-cascading-set-state, orrerender-state-only-in-handlersfor this dialog.UI Changes
No intentional visual changes. The included React Scan recordings show the same add-provider dialog interaction before and after the change.
Checklist
Verification:
bun fmtbun lint(passes with existing warnings)bun typecheckbunx react-doctor@latest apps/web --offline --verbose --jsonNote
Remove derived state effects from AddProviderInstanceDialog
AddProviderInstanceDialoginto a thin wrapper and a newAddProviderInstanceDialogContentcomponent; the wrapper keys the content by theopenprop to force remounts on open/close transitions, replacinguseEffect-based form resets.instanceId/instanceIdDirtystate plus twouseEffecthooks with a single derived value:customInstanceId ?? deriveInstanceId(driver, label). The user's typed value is stored ascustomInstanceId(null means auto-derive).Macroscope summarized 785c91c.