Remove provider environment sync effect#3061
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Contributor
|
🚀 Expo continuous deployment is ready!
|
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
useEffectthat mirrored provider environment props into local draft row state inProviderEnvironmentSection.Why
React Doctor flagged
ProviderInstanceCard.tsxfor synchronous state updates inside an effect. This environment editor already owns draft rows locally during edits and publishes committed rows upward, so the mirror effect added an extra render pass after normal commits. Remounting the editor only when upstream environment values change preserves reset behavior while avoiding the unnecessary effect.UI Changes
Before/after react-scan recordings were captured with react-scan enabled:
react_scan_provider_env_before.mp4react_scan_provider_env_after.mp4React Doctor verification: the post-fix performance scan no longer reports
src/components/settings/ProviderInstanceCard.tsx:165under the synchronous setState-in-effect diagnostic.Checklist
Validation:
react-doctor --verbose --category performance(targeted finding removed; other existing repo findings remain)vp check(passed with existing warnings)vp run typecheck(passed)Note
Replace
useEffectsync with key-based remounting inProviderEnvironmentSectionuseEffectthat keptProviderEnvironmentSection's internalrowsstate in sync withprops.environmentafter mount.getProviderEnvironmentSectionKeyhelper inProviderInstanceCard.tsxthat JSON-stringifies each variable'sname,value,sensitive, andvalueRedactedfields to produce a stable key.ProviderInstanceCardpasses this key toProviderEnvironmentSection, causing the subtree to remount (and re-initialize state from props) whenever environment content changes.ProviderEnvironmentSectionno longer updates its rows in-place when props change — it resets entirely via remount instead.Macroscope summarized f65e38f.