JSX Transform: Classic vs Automatic
What you'll learn: How React changed the way JSX gets compiled, eliminating a common boilerplate requirement.
The Old Way: Classic Transform
For years, JSX compiled to React.createElement() calls. This meant every file using JSX had to import React, even if you never explicitly used it:
import React from 'react'; // Required, even though "React" isn't in your code!
function Button() {
return <button>Click me</button>;
}
Behind the scenes, the transpiler converted that JSX to React.createElement('button', null, 'Click me'), so the React variable was needed—just invisibly.
The New Way: Automatic Transform
Starting with React 17, a new "automatic" JSX runtime was introduced. Now JSX compiles to special jsx() function calls imported automatically by the transpiler:
// No React import needed!
function Button() {
return <button>Click me</button>;
}
The transpiler now adds its own imports behind the scenes (like import { jsx } from 'react/jsx-runtime'), so you don't have to.
Why This Matters
The analogy: It's like switching from manual to automatic transmission. The old way required you to remember the clutch (import React) every time. The new way just... works.
Modern tooling (Vite, Next.js) uses the automatic transform by default. You only see the classic transform in older projects or legacy Babel configs.
Key Takeaway: The automatic JSX transform removes the need to import React in every component file—the transpiler handles the underlying function calls for you.