Summary
Document unsupported syntax in React Compiler (e.g. inside try/catch)
Page
https://react.dev/learn/react-compiler
Details
React Compiler silently skips components it can't compile, which is intentional (panicThreshold: 'none'). But the docs don't say which patterns trigger a skip, so developers can't tell when a component isn't being optimized.
A write up reports that these patterns inside try/catch prevent compilation:
- conditionals (
if/else)
- ternaries, optional chaining and
??
throw
The compiler's own error confirms at least one of these: Todo: Support value blocks (conditional, logical, optional chaining, etc) within a try/catch statement.
These are common in async code (fetch, then check response.ok), so developers may be affected without knowing.
Request:
- Add a list of currently unsupported syntax patterns
Summary
Document unsupported syntax in React Compiler (e.g. inside
try/catch)Page
https://react.dev/learn/react-compiler
Details
React Compiler silently skips components it can't compile, which is intentional (
panicThreshold: 'none'). But the docs don't say which patterns trigger a skip, so developers can't tell when a component isn't being optimized.A write up reports that these patterns inside
try/catchprevent compilation:if/else)??throwThe compiler's own error confirms at least one of these:
Todo: Support value blocks (conditional, logical, optional chaining, etc) within a try/catch statement.These are common in async code (
fetch, then checkresponse.ok), so developers may be affected without knowing.Request: