fix: make Markdown a MemoizationLeaf so Var children stay inlined#6532
Conversation
react-markdown asserts its children prop is a string. Without the snapshot boundary, the auto-memoize plugin hoists a Var child into its own Bare_comp_<hash> element, which renders as [object Object] and crashes the subtree.
Greptile SummaryThis PR fixes a runtime crash where
Confidence Score: 5/5The change is minimal and correctly targeted: swapping the base class for Markdown to MemoizationLeaf prevents the auto-memoize plugin from hoisting Var children out as separate React elements, which was the source of the crash. The fix is a single-line base-class change backed by two levels of tests (a full-compiler unit test and a Playwright integration test). The two review comments flag test-quality concerns — a potential state-name collision in repeated test runs and reliance on internal compiler APIs — neither of which affects production behavior. The test helper Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["rx.markdown(State.var)"] --> B{Markdown base class}
B -->|Before: Component| C["Auto-memoize plugin scans children"]
C --> D["Var child hoisted into Bare_comp_hash React element"]
D --> E["ReactMarkdown receives JSX element as children"]
E --> F["Renders as '[object Object]' / crash"]
B -->|After: MemoizationLeaf| G["_memoization_mode = recursive=False"]
G --> H["Var child stays inlined in snapshot body"]
H --> I["ReactMarkdown receives string interpolation as children"]
I --> J["Renders correctly"]
Reviews (1): Last reviewed commit: "fix: make Markdown a MemoizationLeaf so ..." | Re-trigger Greptile |
Defining the State subclass inside the test body re-registers it on every collection, which leaks under pytest-repeat and duplicate runs. Module scope gives it a stable registry key.
react-markdown asserts its children prop is a string. Without the snapshot boundary, the auto-memoize plugin hoists a Var child into its own Bare_comp_ element, which renders as [object Object] and crashes the subtree.
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features:
closes #6531
fixes ENG-9539