Performance: JSX syntax rules
MEDIUM IMPACT
JSX syntax affects how React components are parsed and rendered, impacting initial load and rendering speed.
const MyComponent = () => { return <div><p>Text</p></div>; };
const MyComponent = () => { return <div><p>Text</p></div>; };
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Incorrect JSX syntax causing errors | 0 (no DOM created) | 0 (render blocked) | 0 (no paint) | [X] Bad |
| JSX with multiple root elements without fragment | 0 (error blocks DOM) | 0 | 0 | [X] Bad |
| Correct JSX with fragments | Minimal DOM nodes | 1 reflow per update | Low paint cost | [OK] Good |
| Correct JSX with proper expressions | Efficient DOM updates | Minimal reflows | Low paint cost | [OK] Good |