Skip to content

fix: move pagination reset out of useMemo into useEffect in RoomsTable#40590

Draft
SiddhiPandey08 wants to merge 2 commits into
RocketChat:developfrom
SiddhiPandey08:fix/rooms-table-usememo-side-effect
Draft

fix: move pagination reset out of useMemo into useEffect in RoomsTable#40590
SiddhiPandey08 wants to merge 2 commits into
RocketChat:developfrom
SiddhiPandey08:fix/rooms-table-usememo-side-effect

Conversation

@SiddhiPandey08
Copy link
Copy Markdown

@SiddhiPandey08 SiddhiPandey08 commented May 17, 2026

Proposed changes (including videos or screenshots)

The setCurrent(0) state setter was being called inside a useMemo
callback to reset pagination when the search text changes. Calling state
setters inside useMemo is a side effect during render, which React
explicitly prohibits — memos must be pure computations.

This PR moves the pagination reset into a useEffect that watches
searchText, and removes the now-unnecessary prevRoomFilterText ref
and useRef import.

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

  • Bug Fixes
    • Admin Rooms: searching now reliably resets pagination to the first page so results and sorting remain consistent.
  • Style / UI
    • Minor rendering cleanup in the Rooms table for improved clarity and stability.

Review Change Stack

Copilot AI review requested due to automatic review settings May 17, 2026 13:43
@SiddhiPandey08 SiddhiPandey08 requested a review from a team as a code owner May 17, 2026 13:43
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 17, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 17, 2026

🦋 Changeset detected

Latest commit: f857af3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 42 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/models Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-composer Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9c1878ae-73ca-452d-bde5-e306c022268a

📥 Commits

Reviewing files that changed from the base of the PR and between 218bfba and f857af3.

📒 Files selected for processing (1)
  • .changeset/odd-hats-kneel.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/odd-hats-kneel.md
📜 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)
  • GitHub Check: cubic · AI code reviewer

Walkthrough

RoomsTable.tsx moves a pagination reset side effect from inside useMemo to a dedicated useEffect hook. The import replaces useRef with useState, the memoized query now always uses the current offset state with updated dependencies, and the table body mapping is formatted across multiple lines. The changeset metadata is updated to release a patch.

Changes

Pagination Reset Refactoring

Layer / File(s) Summary
Hook imports and query construction refactoring
apps/meteor/client/views/admin/rooms/RoomsTable.tsx
React import switches from useRef to useState. Query construction is updated to always use offset: current from state. The useMemo dependencies are synchronized to include current pagination and search state for correct memo recomputation.
Pagination reset via useEffect
apps/meteor/client/views/admin/rooms/RoomsTable.tsx
A useEffect is added that resets current to 0 when the debounced searchText changes, extracting the side effect from useMemo and satisfying React's rendering contract.
Table body rendering expansion
apps/meteor/client/views/admin/rooms/RoomsTable.tsx
GenericTableBody room mapping is expanded into multiple lines for improved readability with no functional changes.
Changeset metadata update
.changeset/odd-hats-kneel.md
Publish a patch for @rocket.chat/meteor and record the RoomsTable pagination reset fix.

🎯 2 (Simple) | ⏱️ ~10 minutes

type: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: moving pagination reset from useMemo to useEffect in RoomsTable.
Linked Issues check ✅ Passed All coding objectives from issue #40589 are met: pagination reset moved from useMemo to useEffect, side effect removed from memo, and behavior preserved.
Out of Scope Changes check ✅ Passed All changes directly address the linked issue; modifications are isolated to RoomsTable.tsx with no unrelated alterations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) from useMemo into a useEffect keyed on searchText
  • Remove the now-unnecessary useRef/prevRoomFilterText logic 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.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@SiddhiPandey08 SiddhiPandey08 marked this pull request as draft May 17, 2026 14:25
@coderabbitai coderabbitai Bot removed the type: bug label May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RoomsTable: Side effect (setCurrent) called inside useMemo violates React rendering contract

2 participants