Skip to content

Document syntax unsupported inside try/catch - #8697

Open
hkwongax wants to merge 2 commits into
reactjs:mainfrom
hkwongax:docs-compiler-unsupported-syntax
Open

hkwongax wants to merge 2 commits into
reactjs:mainfrom
hkwongax:docs-compiler-unsupported-syntax

Conversation

@hkwongax

Copy link
Copy Markdown

Fixes #8685

Documents the syntax patterns that currently prevent compilation inside try/catch statements.

  • Conditional expressions (ternaries, &&, ||, ??), optional chaining, throw statements, and loops are not supported inside try/catch statements yet; the compiler skips the component.
  • The same patterns are supported outside of try/catch, with a small example showing the workaround.
  • Points at the existing ways to notice skipped components (the ✨ badge in React DevTools, and the logger option).

I placed this on the Debugging and Troubleshooting page because it already promises to cover "Common patterns that break compilation" and is the page linked from the overview for diagnosing skips.

Verification

I checked each pattern against babel-plugin-react-compiler 1.0.0 (the version in this repo's devDependencies) by compiling small snippets and reading the compiler's logger events:

  • Skipped inside try/catch: ternary, &&, ||, ??, optional chaining, throw, for, for...of, while.
  • Compiled fine inside try/catch: plain if/else, switch, and array methods such as .map().
  • Everything above compiles fine outside of try/catch.

The original report also listed plain if conditionals as unsupported inside try/catch, but those compile fine now, so the list is limited to patterns I could reproduce.

The added example code block compiles cleanly with the compiler, and the new heading follows the repo's anchor conventions.

@github-actions

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

This branch was successfully deployed

1 active deployment
Preview — 52924f42 Deployed Oct 16, 2026 by vercel[bot]
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.

[Suggestion]: Document unsupported syntax in React Compiler (e.g. inside try/catch)

1 participant