r/reactjs • • May 19 '26

Resource Auto generate skeleton loading divs with this library.

You know the feeling. You have 8 cards on screen. Each one has its own shimmer animation. They all start at slightly different times. The whole page just... flickers chaotically.

I spent way too long accepting this as normal. Then I built shimmer-trace to fix it.

The core idea is simple: Instead of animating each skeleton block separately, the library renders your real component invisibly, traces every element's exact shape using getBoundingClientRect, and paints one single shimmer wave across the whole page using a CSS mask.

The result looks noticeably more premium. One clean wave instead of chaos.
🔗 Demo: https://jeetvora331.github.io/shimmer-trace/

Usage is literally one line:

// Before: manual skeleton hell
<SkeletonRect width="100%" height={24} borderRadius={8} />
<SkeletonRect width="60%" height={16} borderRadius={4} />
<SkeletonCircle size={48} />

// After: just wrap it
<Shimmer loading={loading}>
  <UserCard />
</Shimmer>

No <SkeletonCard />. No grey div juggling. No layout shift. Your real component already knows its shape — the library just reads it.

Hit 500+ downloads last weekend. Would love harsh feedback from this community specifically, what edge cases would break this for your use case?

⭐ GitHub: https://github.com/jeetvora331/shimmer-trace
🔗 npmjs: https://www.npmjs.com/package/shimmer-trace

0 Upvotes

13 comments sorted by

View all comments

Show parent comment

-6

u/quintin331 May 20 '26

Hey u/Scientist_ShadySide appreciate the deep-dive, but you read the partial README, not the source. Going point by point:

1. getBoundingClientRect forces layout — correct, and I'll optimize it.
2. "Invisible render is a real DOM render … double-fetch" — this one's wrong.
3. SSR / RSC — valid, one-line fix -> Adding 'use client'
4. Dynamic / async content drift
The skeleton reflects the props you pass via dummyData. Pass name: 'xxxxxxxxxx' and you get a name-shaped block. Pass nothing and you get the empty-state shape — that's documented and intentional. Variable-length text always drifts on any auto-tracing library; that's why dummyData exists. Not magic, but not broken either.
5. Portals / fixed / transform — mixed.

  • Portals: correct, they're skipped because collectTraceableElements walks the subtree only. Will document and add a data-shimmer attribute escape hatch for cross-tree elements.
  • position:fixed: correct edge case; rare inside a shimmer tree, but I'll document.
  • Transformed ancestors: the overlay sits inside the same container, so it shares the transform. Renders fine in practice. Did you actually reproduce a broken mask here?

6. "Resize / responsive layouts are unhandled" — this is just wrong.
useTrace.ts:167-170 attaches a ResizeObserver to the container and re-traces on resize. Has since v1.0. Took 30 seconds to verify.

If you've got a real repro of any of these breaking then open an issue and I will try to fix this