Performance: Error.tsx for route errors
MEDIUM IMPACT
This affects how quickly error pages render during route failures, impacting user experience during navigation errors.
'use client'; export default function Error({error, reset}) { return ( <div role="alert" aria-live="assertive"> An error occurred. <button onClick={reset}>Please try again later.</button> </div> ); }
'use client'; export default function Error({error, reset}) { // Heavy logic inside error component let data = 0; for(let i = 0; i < 10000000; i++) { data += i; } return <div>Error occurred: {data}</div>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy synchronous logic in Error.tsx | Increased DOM nodes if rendering fetched data | Multiple reflows due to async updates | High paint cost due to delayed rendering | [X] Bad |
| Static, simple Error.tsx with ARIA roles | Minimal DOM nodes | Single reflow on initial render | Low paint cost with immediate display | [OK] Good |