[FIX] [V2] Conditional expressions in Babel Plugin's content retrieval#1241
Merged
cdn34dd merged 1 commit intofeature/v2from Apr 9, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where conditional JSX expressions (ternary operators and logical operators) inside Pressable components with useCallback handlers were emitted as raw JSX in the bundle, causing Hermes compilation failures. The fix adds recursive processing and dedicated handlers for ConditionalExpression and LogicalExpression AST nodes in the jsxChildToRuntimeCall function, ensuring all JSX within conditional branches is properly converted to jsx() runtime calls.
Changes:
- Added
ConditionalExpressionhandler to recursively convert JSX in both branches of ternary expressions - Added
LogicalExpressionhandler to recursively convert JSX in the right operand of logical operators - Modified
JSXExpressionContainerhandling to recursively process inner expressions instead of directly cloning them - Added comprehensive test cases covering ternary operators, logical operators, nested conditionals, and the useCallback scenario from the issue
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react-native-babel-plugin/src/actions/rum/index.ts | Modified jsxChildToRuntimeCall function to recursively handle conditional and logical expressions containing JSX |
| packages/react-native-babel-plugin/test/plugin.test.ts | Added 5 new test cases validating JSX conversion in conditional expression contexts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
marco-saia-datadog
approved these changes
Apr 8, 2026
38875c0 to
713c88a
Compare
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fix raw JSX in getContent closure for conditional expressions, by adding
ConditionalExpressionandLogicalExpressionhandlers to recursively convert JSX inside expression branches.Motivation
Issue #1238.
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)