Skip to content

Rule · Lint

WebGL canvas rendered inside .map()

lint/webgl-in-maperrorvoid lintupdated

Why it matters

Browsers cap live WebGL contexts at roughly 8–16 per page and silently evict the oldest one, so lists of shader avatars/cards go blank. Each context also costs GPU memory and a render loop.

How to fix it

Render one shared canvas (e.g. a single with many meshes, or @react-three/drei View), use a static frame/CSS gradient per item, or mount the WebGL piece only for the hovered/visible item.

Example

tsx
// one context, many views
<Canvas eventSource={ref}><View.Port /></Canvas>
{items.map((i) => <View key={i.id}><Orb seed={i.id} /></View>)}

References

void lint reports 67 rules in this category. Static source checks with no browser: Tailwind v4 silent failures, Next.js 16 API traps, React render-body bugs, accessibility markup, SEO files and motion hygiene.