Skip to content

preserve prop names to some degree with memo#5777

Merged
adhami3310 merged 2 commits intomainfrom
preserve-prop-names-to-some-degree-with-memo
Sep 10, 2025
Merged

preserve prop names to some degree with memo#5777
adhami3310 merged 2 commits intomainfrom
preserve-prop-names-to-some-degree-with-memo

Conversation

@adhami3310
Copy link
Member

No description provided.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR refactors the React memoization system in Reflex to preserve component prop names while maintaining memo functionality. The key change moves memo markers from prop names themselves to JavaScript expression variables, which prevents prop name pollution in the component interface.

The changes span multiple files:

  1. Component System (component.py): The core change modifies how memoized custom components handle props. Previously, the MEMO_MARKER suffix was added directly to event trigger prop names and camel-cased props. Now, the original prop names are preserved, and the memo marker is only applied at the JavaScript expression level through get_prop_vars() using the new CAMEL_CASE_MEMO_MARKER.

  2. Template Generation (templates.py): The React component template now uses destructuring assignment with renamed variables ({prop}:{prop}RxMemo) instead of modifying prop names directly. This preserves the original prop names while creating internal variables with the memo marker for React's memoization process.

  3. Compilation Pipeline (app.py, compiler.py): Variable and function names are updated from custom_components_* to memo_components_* to better reflect their actual purpose of handling memoized components specifically.

  4. Constants (state.py): A new CAMEL_CASE_MEMO_MARKER constant ('RxMemo') is added for JavaScript/React compatibility.

This refactoring improves the separation of concerns between internal memo implementation and external component API, ensuring that consumers of these components see clean prop names while maintaining the performance benefits of React memoization.

Confidence score: 4/5

  • This PR is safe to merge with careful review of memo functionality
  • Score reflects good architectural separation but complexity around memoization logic requires attention
  • Pay close attention to component.py and templates.py for memo behavior verification

5 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 10, 2025

CodSpeed Performance Report

Merging #5777 will not alter performance

Comparing preserve-prop-names-to-some-degree-with-memo (a62f176) with main (a605e7a)

Summary

✅ 8 untouched benchmarks

@adhami3310 adhami3310 merged commit caab8ba into main Sep 10, 2025
40 of 41 checks passed
@adhami3310 adhami3310 deleted the preserve-prop-names-to-some-degree-with-memo branch September 10, 2025 21:37
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