Skip to content

Auto-memo wrapper tags for @rx.memo components repeat the inner tag #6955

Description

@FarhanAliRaza

Follow-up from #6949 (auto-memoize @rx.memo call sites with stateful props). Cosmetic only.

Problem

The generated wrapper around a user @rx.memo component gets a tag like:

Memocomponent_card_98ffd1e1_card_98ffd1e1_e52460d9ed338b99ee51cd718b2b8fa7_98ffd1e1

The inner tag appears twice. The name is noisy in compiled app_components/*.jsx output, React DevTools, and stack traces.

Cause

Component._compute_memo_tag() (packages/reflex-base/src/reflex_base/components/component.py) builds the prefix as f"{type(self).__qualname__}_{self.tag or 'Comp'}_{comp_hash}". For a MemoComponent instance, type(self) is the dynamic subclass from _get_memo_component_class, whose __qualname__ equals its tag (Card_98ffd1e1), so the qualname and tag segments are identical. The qualname is there to keep distinct classes with identical render output from colliding; for memo subclasses the tag already carries that identity. The trailing _98ffd1e1 is the module suffix added a second time by _create_component_definition.

Suggested fix

In _compute_memo_tag, skip the self.tag segment when it equals type(self).__qualname__ (or override _compute_memo_tag on MemoComponent to use Memocomponent_{tag}_{hash}). Keep the class identity in the name so the collision guarantee from the docstring holds. Add a unit test in tests/units/compiler/test_memoize_plugin.py asserting the wrapper tag for a user memo contains the inner tag once.

Repro

Any @rx.memo component called with a state Var prop; inspect .web/app_components/<app>/<app>.jsx after reflex run.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions