---
id: wiki-2026-0508-jsx
title: JSX
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [JavaScript XML, React JSX, TSX]
duplicate_of: none
source_trust_level: A
confidence_score: 0.95
verification_status: applied
tags: [jsx, react, typescript, transpilation]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: typescript
framework: react
---
# JSX
## 매 한 줄
> **"매 syntactic sugar over `createElement` — XML-like JS expression"**. React 의 발명, 매 declarative UI 의 핵심. 매 `
x
` → `jsx('div', null, 'x')` 로 transpile. 2026 default 는 **automatic runtime** (`react/jsx-runtime`) — 매 `import React` 의 불필요.
## 매 핵심
### 매 transpile model
- **Classic runtime** (legacy): `` → `React.createElement('div', null)` — 매 file 마다 `import React` 필요.
- **Automatic runtime** (2020+, default): `` → `_jsx('div', null)`, runtime 의 자동 import.
- **Preserve**: TS `--jsx preserve` — Babel 등 다른 tool 에 위임.
### 매 element types
- **Lowercase** (`div`, `span`): 매 string tag, host component.
- **Uppercase** (`Foo`): 매 reference, component identifier.
- **Member access** (`Lib.Btn`): 매 namespaced component.
- **Fragment** (`<>...>`): 매 wrapper-less group.
### 매 응용
1. React / Preact / Solid / Qwik 의 매 component definition.
2. MDX — Markdown + JSX.
3. JSX as data (Astro, hyperscript variant).
## 💻 패턴
### Automatic runtime (2026 default)
```tsx
// tsconfig.json
{
"compilerOptions": {
"jsx": "react-jsx", // 매 automatic runtime
"jsxImportSource": "react" // or "preact", "@emotion/react"
}
}
// Component.tsx — 매 import React 의 X
export function Hello({ name }: { name: string }) {
return Hello, {name}
;
}
```
### Conditional rendering
```tsx
function Status({ user }: { user?: User }) {
if (!user) return null;
return (
<>
{user.isAdmin && }
{user.posts.length > 0
?
: }
>
);
}
```
### Children pattern
```tsx
type Props = { title: string; children: React.ReactNode };
function Card({ title, children }: Props) {
return (
);
}
```
### Render prop / function-as-children
```tsx
type DataLoaderProps = {
url: string;
children: (data: T | undefined, loading: boolean) => React.ReactNode;
};
function DataLoader({ url, children }: DataLoaderProps) {
const [data, setData] = useState();
const [loading, setLoading] = useState(true);
useEffect(() => {
fetch(url).then(r => r.json()).then(d => { setData(d); setLoading(false); });
}, [url]);
return <>{children(data, loading)}>;
}
```
### Polymorphic component (`as` prop)
```tsx
type AsProp = { as?: C };
type PolymorphicProps =
AsProp & React.ComponentPropsWithoutRef;
function Box({
as, ...rest
}: PolymorphicProps) {
const Comp = as ?? 'div';
return ;
}
// 매 anchor props 의 typed
```
### JSX spread + override
```tsx
function PrimaryButton(props: React.ButtonHTMLAttributes) {
return ;
}
```
### Fragment + key
```tsx
function List({ items }: { items: Item[] }) {
return (
{items.map(it => (
- {it.term}
- {it.def}
))}
);
}
```
### TypeScript — JSX.IntrinsicElements override
```tsx
declare global {
namespace JSX {
interface IntrinsicElements {
'my-web-component': React.DetailedHTMLProps<
React.HTMLAttributes & { value?: string },
HTMLElement
>;
}
}
}
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| 새 React project | `"jsx": "react-jsx"` (automatic) |
| Preact / Solid | `jsxImportSource` 적절 설정 |
| Babel 사용 | `"jsx": "preserve"` + babel preset |
| Web component 통합 | `JSX.IntrinsicElements` 확장 |
| 매 server component | `"jsx": "react-jsx"` (RSC 호환) |
**기본값**: automatic runtime + TypeScript strict.
## 🔗 Graph
- 부모: [[React]] · [[TypeScript]]
- 변형: [[TSX]] · [[MDX]]
- Adjacent: [[SWC]] · [[esbuild]]
## 🤖 LLM 활용
**언제**: React/Preact/Solid component 작성, TS JSX 설정 디버깅, polymorphic API 설계.
**언제 X**: 매 plain HTML template (no transpile needed), 매 Vue SFC (`` 별 syntax).
## ❌ 안티패턴
- **`React` import 누락 (classic runtime)**: 매 `react-jsx` 로 migrate.
- **lowercase component name**: `` 매 host element 로 처리됨 — 매 PascalCase 강제.
- **`key` 누락 in list**: reconciliation 비용 폭증.
- **inline function child 의 남발**: render 마다 새 reference — memoized child re-render 유발.
## 🧪 검증 / 중복
- Verified (react.dev JSX docs, TS Handbook JSX, React 19 RC notes).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — JSX automatic runtime + polymorphic patterns 정리 |