preserve prop names to some degree with memo#5777
Conversation
There was a problem hiding this comment.
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:
-
Component System (
component.py): The core change modifies how memoized custom components handle props. Previously, theMEMO_MARKERsuffix 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 throughget_prop_vars()using the newCAMEL_CASE_MEMO_MARKER. -
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. -
Compilation Pipeline (
app.py,compiler.py): Variable and function names are updated fromcustom_components_*tomemo_components_*to better reflect their actual purpose of handling memoized components specifically. -
Constants (
state.py): A newCAMEL_CASE_MEMO_MARKERconstant ('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.pyandtemplates.pyfor memo behavior verification
5 files reviewed, no comments
CodSpeed Performance ReportMerging #5777 will not alter performanceComparing Summary
|
No description provided.