Skip to content

Refactor DynamicList and ReactUtil#10

Merged
OutOfBears merged 2 commits into
OutOfBears:mainfrom
RBXTyler:main
Oct 28, 2025
Merged

Refactor DynamicList and ReactUtil#10
OutOfBears merged 2 commits into
OutOfBears:mainfrom
RBXTyler:main

Conversation

@RBXTyler

Copy link
Copy Markdown
Contributor

This pull request refactors the DynamicList component and its supporting utility to improve React element reconciliation, reduce unnecessary prop mutations, and prevent excessive re-rendering and potential loops. The main changes focus on only wrapping children flagged for removal, using shallow copies to preserve type information, and bailing out updates when no changes are detected.

DynamicList reconciliation improvements:

  • The DynamicList component now only wraps children flagged for removal with removal props, rather than wrapping all children each render. This reduces unnecessary churn and prevents infinite update loops.
  • The update logic now bails out early if there are no changes to the children, avoiding unnecessary state updates and re-renders.

React element copying strategy:

  • The updateReactChild function in ReactUtil.lua now performs a shallow copy of React element descriptors instead of a deep copy, preserving Luau's refined type information and avoiding issues with 'unknown' types for consumers.
  • The utility no longer forcibly sets the type field after copying, as the shallow copy preserves all fields.

@OutOfBears
OutOfBears merged commit 60b7767 into OutOfBears:main Oct 28, 2025
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