StyleErrorBoundary
Location: src/components/StyleErrorBoundary.jsx
Overview
A React error boundary that catches rendering errors caused by token-based styling (corrupt tokens, bad computed values, etc.) and silently falls back to default/unstyled rendering. Unlike the global ErrorBoundary, this does NOT show an error page — the feed and HomeRoom continue working with the affected item rendered without custom tokens.
Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
children | ReactNode | Yes | -- | The token-styled rendering to protect |
fallback | ReactNode | No | children | What to render when an error occurs. Typically the same content without token styling. |
Usage
import StyleErrorBoundary from './StyleErrorBoundary';
// In Post.jsx — wraps the token-styled wrapper
if (hasTokenStyle) {
return (
<StyleErrorBoundary fallback={articleEl}>
<div style={tokenOuterStyle} className="post-token-wrapper">
{articleEl}
</div>
</StyleErrorBoundary>
);
}
// In HomeRoom.jsx — wraps token-styled module cards
<StyleErrorBoundary fallback={defaultRendering}>
<section className={`module-${module.module_type}`}>
{/* token-styled card */}
</section>
</StyleErrorBoundary>
How It Works
- Wraps token-styled rendering in an error boundary
- If any child throws during render (e.g.
colors.priis undefined,clipPathscomputation fails):- Logs the error to console via
componentDidCatch - Returns
fallbackprop (the unstyled version) orchildrenif no fallback provided
- Logs the error to console via
- The parent feed/room continues rendering normally — only the affected post/module loses its custom style
Where It's Used
- Post.jsx — Wraps
post-token-wrapperdiv (the clip-path border wrapper for styled posts) - HomeRoom.jsx — Wraps token-styled module cards in
HomeRoomModule
Related
ErrorBoundary(src/components/ErrorBoundary.jsx) — Global error boundary that shows a reload pagevalidateTokens(src/contexts/StyleContext.jsx) — Pre-rendering validation that prevents most errorscomputeStyle(src/contexts/StyleContext.jsx) — Try/catch wrapper that returns defaults on computation failure
Last updated: 2026-02-08