fix: skip toggleExpanded when state already matches desired value#6194
fix: skip toggleExpanded when state already matches desired value#6194isaackaara wants to merge 1 commit intoTanStack:mainfrom
Conversation
When calling row.toggleExpanded(bool) with a value that matches the current expanded state, the function now returns early without calling setExpanded. This prevents unnecessary re-renders when the expanded state is not actually changing. Previously, even no-op calls to toggleExpanded would invoke the state updater, which could trigger re-renders in React and cause noticeable UI freezes during rapid interactions like tab-navigating between inputs. Fixes TanStack#6136
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
When calling
row.toggleExpanded(bool)with a value that matches the current expanded state, the function now returns early without callingsetExpanded. This prevents unnecessary re-renders when the expanded state is not actually changing.Previously, even no-op calls to
toggleExpandedwould invoke the state updater, which could trigger re-renders in React and cause noticeable UI freezes during rapid interactions like tab-navigating between inputs.The fix checks
row.getIsExpanded()before invoking the state setter. If the desired value matches the current state, it bails out immediately. The internal updater logic is also simplified since after the early return, we know the state IS changing, so the exists/expanded conditionals collapse.Fixes #6136