Skip to content

[v4 + css-interop] Animated.ScrollView loses ref (useAnimatedRef null) on Expo 54 / Reanimated 4 when using NativeWind runtime #257

@alvaroyecla

Description

@alvaroyecla

Describe the bug

With NativeWind v4 (css-interop runtime), an animated ScrollView loses its ref when rendered via Animated.ScrollView or Animated.createAnimatedComponent(ScrollView).
useAnimatedRef() returns a handle that never reaches the native node, so calling scrollTo(ref, …) from a worklet does nothing (and log Value is null, expected an object).

If I render the same ScrollView outside the css-interop runtime (wrapper with /** @jsxImportSource react */ + forwardRef) and then animate that wrapper, the ref is valid and scrollTo works.

Reproduction

How to run

git clone https://github.com/alvaroyecla/my-expo-app.git
cd my-expo-app
npm i
npx expo start -c

Expected behavior

  • Rendering Animated.ScrollView (or Animated.createAnimatedComponent(ScrollView)) must forward the ref even when the css-interop runtime is active.
  • useAnimatedRef() returns a valid (non-null) animated ref as soon as the view is mounted.
  • Calling scrollTo(ref, x, y, animated) from a worklet (e.g. via scheduleOnUI + useDerivedValue) scrolls reliably by the requested offset.
  • The presence of className (i.e., going through the NativeWind runtime) must not change ref semantics compared with inline style.
  • No errors such as Value is null, expected an object should be emitted.

Additional context
Related:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions