Skip to content

Rule · Lint

Hook called inside a JSX expression, &&, ternary or callback

lint/conditional-hookerrorvoid lintupdated

Why it matters

{mode === 'gradient' && }} />} (Magic UI magic-card) or style={{ y: useTransform(…) }} (Skiper19) changes hook order when the condition flips; React throws "Rendered more hooks than during the previous render".

How to fix it

Call every hook unconditionally at the top of the component and use the result conditionally.

Example

tsx
const background = useMotionTemplate`radial-gradient(${size}px at ${x}px ${y}px, var(--brand-subtle), transparent)`;
return mode === 'gradient' ? <motion.div style={{ background }} /> : null;

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.