Skip to content

fix(interactions): give factories a live view of the animation - #136

Merged
Gamote merged 1 commit into
mainfrom
fix/live-interaction-context
Aug 16, 2026
Merged

fix(interactions): give factories a live view of the animation#136
Gamote merged 1 commit into
mainfrom
fix/live-interaction-context

Conversation

@Gamote

@Gamote Gamote commented Aug 16, 2026

Copy link
Copy Markdown
Owner

What

useInteractionsRunner handed every factory the current animation through a getter on the context. The animation object a hook returns is rebuilt on every render, so a factory that kept what it was handed, const { lottie } = context, the natural thing to write, kept that render's values: root stayed null when the element mounted after attach, which on a prerendered page is always. The two shipped factories read the context on every use and were unaffected; the docs' custom-factory example was not, and never armed on a direct load.

The context now carries one live view per animation: an object whose members are getters onto the current instance, built from the instance's own keys (the same shape React Hook Form uses for its proxied form state), cached per animation for the runner's life. Keeping or destructuring it is safe; a value pulled out of it is a copy of that moment, as any value is. No public type changes. The custom-factory example returns to the destructuring form, and the contract's JSDoc and the "Writing your own" page say the view is live.

Verified

  • Two new tests, red-first on the old runner: a copy taken at attach sees the root arrive, the state move and its commands reach the animation, and exposes every member of the instance; the view is one stable object across reads and across a re-arm. The six identity assertions on context.lottie now prove "this context drives that animation" through subscribe, one function per animation for its life.
  • pnpm check green: 480 tests, coverage 100 / 97.43 / 100 / 100, budgets unchanged, 34 pages rendered.
  • Real browser: the built site's destructuring example registers its listener and plays on a direct load of "Writing your own"; the packed build in a Next.js 16 Turbopack app, a prerendered page with a destructuring factory, direct-loaded: plays while pressed and pauses on release, where the previous build stayed on frame 0.

The animation object a hook returns is rebuilt on every render, and the
runner handed factories that object through a getter, so a factory that
kept what it was handed (`const { lottie } = context`) kept that render's
values: `root` stayed `null` when the element mounted after attach, which
on a prerendered page is always.

The context now carries one view per animation whose members are getters
onto the current instance, so keeping or destructuring it is safe and a
value pulled out of it is a copy of that moment, as any value is. The
docs' custom-factory example returns to the natural destructuring form,
and the contract's JSDoc and page say the view is live.
@Gamote
Gamote merged commit 9e67c64 into main Aug 16, 2026
4 checks passed
@Gamote
Gamote deleted the fix/live-interaction-context branch August 16, 2026 15:19
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.91%. Comparing base (aace264) to head (0589b7d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #136   +/-   ##
=======================================
  Coverage   99.91%   99.91%           
=======================================
  Files          47       47           
  Lines        1223     1232    +9     
  Branches      361      362    +1     
=======================================
+ Hits         1222     1231    +9     
  Misses          1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Gamote Gamote mentioned this pull request Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant