Skip to content

fix: refresh virtual rows when rowKey changes - #64

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/update-virtual-row-key
Open

fix: refresh virtual rows when rowKey changes#64
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/update-virtual-row-key

Conversation

@nrps9909

Copy link
Copy Markdown

Summary

  • make the item-key getter change identity when the rowKey contract changes
  • let VirtualList recompute its memoized flattened rows and key lookups on that change
  • add an integration regression that rerenders the same item array from rowKey="id" to rowKey="slug"

Root cause

useItemKey returned a stable useEvent function, while useFlattenRows used that function as a memo dependency. Changing rowKey with the same items array therefore left the virtual rows memoized under the old tagged keys. Raw mode called the latest event function during render, so the two modes diverged.

Verification

  • exact base: f71de19007a04a1689c78cec1a612c2ca2af2983
  • regression before the fix: after rerendering from rowKey="id" to rowKey="slug", the virtual row remained item:1 instead of item:first
  • focused regression — 1/1 passed after the fix
  • npm test -- --runInBand — 4 suites, 51 tests, 1 snapshot passed
  • npm run lint — passed
  • npm run compile — ESM, CJS, declarations, and Less build passed
  • changed-file Prettier check and git diff --check — passed

AI assistance disclosure: Codex was used to trace the stale memo dependency, construct the exact-base rerender regression, implement the scoped fix, and draft this report. I verified the before/after key values and all listed checks locally.

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 547b0f02-91c0-41c0-996f-6d15f2894548


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.

@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f71de19) to head (c6a7985).

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #64   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          216       216           
  Branches        56        55    -1     
=========================================
  Hits           216       216           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants