00Labs · TIL

Framer Motion whileInView does not fire on mount under next dev (StrictMode)

Above-the-fold reveals stay masked under next dev until you scroll. The cause is the StrictMode double mount, not your code. In a production build, whileInView fires correctly.

· 1 min read · updated

Symptom

Above-the-fold headlines stayed masked under next dev until the first scroll. Further down the page everything ran normally. Looked like a broken reveal.

Cause

It was StrictMode. In development React deliberately mounts components twice, and the double mount disconnects framer's IntersectionObserver before its first callback lands. No callback, no animate, so the text just sits under its mask. Only the next scroll triggers a fresh observation.

next build and next start fire correctly at mount, because a production build has no double mount.

To cross-check:

npm run build && npm run start

Same page, same viewport: on the production server the headlines appear right away.

Fix

No code fix needed. QA reveals against a production build, not against the dev server, otherwise you are debugging an artifact.

There is a real whileInView trap that looks similar, though: the element you observe must not itself be pushed out of an overflow: hidden container. Then the IntersectionObserver sees zero area and never fires, in production too. That is why components/motion/Reveal.tsx observes the unclipped parent and drives the child through variants:

<motion.div style={{ overflow: "hidden" }} initial="hidden" whileInView="show">
  <motion.div variants={{ hidden: { y: "115%" }, show: { y: "0%" } }}>
    {children}
  </motion.div>
</motion.div>

If a reveal stays stuck in a production build as well, it is this case and not StrictMode.

Tested with framer-motion 12.38, React 19.2.4, Next.js 16.2.5.

See also