Skip to content

fix(presets): Reanimated's animated hooks run on one mapper scheduler, as its mappers do - #816

Draft
danfry1 wants to merge 15 commits into
mainfrom
fix/reanimated-render-only-hooks
Draft

danfry1 wants to merge 15 commits into
mainfrom
fix/reanimated-render-only-hooks

Conversation

@danfry1

@danfry1 danfry1 commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

useDerivedValue, useAnimatedStyle, useAnimatedProps and useAnimatedReaction from react-native-reanimated now run on one mapper scheduler modelled on Reanimated's mappers.ts. Styles and props follow the shared values they read without a render, and reactions run. Fixes #754.

Why

Reanimated's own test mock, and the built-in preset for older versions, ran the style and props updaters only at render and never called a reaction. A test that called progress.set(0.5) and then toHaveAnimatedStyle saw the old style, and a child React skipped (for example one React Compiler memoized) kept its first one.

Changes

  • One scheduler in presets/reanimated.ts. A write marks every mapper that read the value dirty, then runs one pass in topological order, each mapper once. A write made during a pass does not start another (processingMappers). A mapper that writes its own input stays dirty for the next pass. Mappers start in an effect and stop on unmount.
  • A component's animated style is one object. Each result merges into it, as Reanimated's Jest path does. The updater's own objects are never written.
  • Reactions run on mount and on each change, with Reanimated's previous and dependency rules. Each run uses the latest committed render's functions.
  • The four hooks replace Reanimated 4.7's mock only while its hooks are render-only. The probe uses the mock's own shared value where it has one.
  • A new "Reanimated's animated hooks" section in the presets guide, a minor changeset listing what changes for existing tests, and a bug museum exhibit, pre-754-reanimated-animated-style-stale.

Notes

@danfry1 danfry1 added this to the 0.15.1 milestone Nov 14, 2026
@danfry1 danfry1 added enhancement New feature or request area:presets Built-in presets and libraries' own mocks labels Nov 14, 2026
@danfry1 danfry1 modified the milestones: 0.15.1, 0.16.0 Nov 14, 2026
@danfry1 danfry1 changed the title fix(presets): Reanimated animated styles, props and reactions follow the shared values they read fix(presets): Reanimated's animated hooks run on one mapper scheduler, as its mappers do Nov 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:presets Built-in presets and libraries' own mocks enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reanimated: useAnimatedStyle, useAnimatedProps and useAnimatedReaction act only at render

1 participant