fix: move pagination reset out of useMemo into useEffect in RoomsTable#40590
fix: move pagination reset out of useMemo into useEffect in RoomsTable#40590SiddhiPandey08 wants to merge 2 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: f857af3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 42 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Walkthrough
ChangesPagination Reset Refactoring
🎯 2 (Simple) | ⏱️ ~10 minutes type: bug 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Pull request overview
This PR fixes a React rendering-contract violation in the Admin Rooms table by removing a state update (setCurrent(0)) from a useMemo and performing the pagination reset in a useEffect when the debounced search text changes.
Changes:
- Move pagination reset (
setCurrent(0)) fromuseMemointo auseEffectkeyed onsearchText - Remove the now-unnecessary
useRef/prevRoomFilterTextlogic and simplify the query memoization - Minor JSX formatting cleanup for the table body rows
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Proposed changes (including videos or screenshots)
The
setCurrent(0)state setter was being called inside auseMemocallback to reset pagination when the search text changes. Calling state
setters inside
useMemois a side effect during render, which Reactexplicitly prohibits — memos must be pure computations.
This PR moves the pagination reset into a
useEffectthat watchessearchText, and removes the now-unnecessaryprevRoomFilterTextrefand
useRefimport.Issue(s)
Fixes #40589
Steps to test or reproduce
No visual regression expected. The pagination reset behavior on search
text change is preserved — it now happens correctly in a useEffect
instead of as a side effect during render.
To verify: navigate to Admin > Rooms, type in the search box, confirm
pagination resets to page 1.
Further comments
Checked UsersTable.tsx and ChannelsTable.tsx — neither has this pattern.
Fix is isolated to RoomsTable.tsx.
Summary by CodeRabbit