Skip to content

fix: resolve "measureLayout must be called with a ref to a native component" warning#620

Open
RyadPasha wants to merge 1 commit into
computerjazz:mainfrom
RyadPasha:fix/measureLayout-native-component-warning
Open

fix: resolve "measureLayout must be called with a ref to a native component" warning#620
RyadPasha wants to merge 1 commit into
computerjazz:mainfrom
RyadPasha:fix/measureLayout-native-component-warning

Conversation

@RyadPasha
Copy link
Copy Markdown

Problem

When using NestableDraggableFlatList inside a NestableScrollContainer, React Native logs the following warning on every layout:

Warning: ref.measureLayout must be called with a ref to a native component.

This fires from two places:

  • NestableDraggableFlatList.tsx .. containerRef.current.measureLayout(...)
  • CellRendererComponent.tsx .. viewNode.measureLayout(...)

Both call .measureLayout() directly on composite (JS/Animated) component refs, not on host (native) views. React Native requires the caller ref to be a native component.

Fix

Replace both call sites with UIManager.measureLayout(), which accepts native node handles (numbers) resolved via findNodeHandle(). This is the correct low-level API for measuring across arbitrary component trees.

Note: UIManager.measureLayout has a different argument order than ref.measureLayout(node, relativeToNode, onFail, onSuccess).

Tested on

  • iOS Simulator (React Native 0.81.5)

…e handles

Calling ref.measureLayout() directly on composite (JS) component refs
triggers a React Native warning: "ref.measureLayout must be called with
a ref to a native component." This happens because containerRef and
viewRef point to wrapped/Animated components, not host views.

Fix both call sites to use UIManager.measureLayout() with findNodeHandle()
to first resolve refs to their underlying native node handles before
measuring.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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