fix: maximum depth exceeded state update#1847
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses React “Maximum update depth exceeded” errors by removing effect-synced “derived state” in several UI components and instead deriving values during render (memoized where appropriate). This reduces nested update cascades caused by inline props (arrays/functions) that change identity on every parent render.
Changes:
- Tabs: replace effect-driven
activeTab/filteredTabsstate withuseMemo-derived values. - Combobox variants: remove effect-synced
selectedItem/label/title state and derive them during render (memoized). - Anonymous Apex: remove a redundant
results -> visibleResultssyncing effect and rely on the single filtering effect.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/ui/src/lib/tabs/Tabs.tsx | Stops mirroring activeTab/filteredTabs into state to avoid nested update cascades. |
| libs/ui/src/lib/form/combobox/ComboboxWithItemsVirtual.tsx | Derives selection + labels during render to avoid effect-triggered state updates. |
| libs/ui/src/lib/form/combobox/ComboboxWithItemsTypeAhead.tsx | Same derived-selection approach to prevent repeated effect-driven updates. |
| libs/ui/src/lib/form/combobox/ComboboxWithItems.tsx | Removes effect-synced derived state for selection/labels/titles (memoized). |
| libs/ui/src/lib/form/combobox/ComboboxWithGroupedItems.tsx | Same derived-selection approach for grouped items. |
| libs/features/anon-apex/src/AnonymousApex.tsx | Removes redundant state sync effect, reducing extra render cycles. |
Refs: betterstack errors 9d9b4c94090709233f3a25c00b4b45e8c8cf252903f6972e77fb442bcbcb48ee e254a767a2d54e918254ac478b1433ff938d46df381665779bc03ccafe933b17
dc72685 to
ba00a92
Compare
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.
fix: maximum depth exceeded state update
Refs: betterstack errors 9d9b4c94090709233f3a25c00b4b45e8c8cf252903f6972e77fb442bcbcb48ee e254a767a2d54e918254ac478b1433ff938d46df381665779bc03ccafe933b17