Skip to content

Conversation

@mfazekas
Copy link
Contributor

@mfazekas mfazekas commented Nov 30, 2025

Summary

Fixes "Unknown reactTag" errors when calling native methods immediately after receiving a ref callback on iOS.

Before: Native modules immediately rejected with "Unknown reactTag" when the JS ref was available but native view wasn't registered yet.

After: Uses RNMBXViewResolver (already used by MapView) which polls with progressive delays until the view is found.

See #4098

Affected modules

  • ShapeSource
  • PointAnnotation
  • Image
  • Camera
  • Viewport

Reproducer

const BugReportExample = () => {
  const [showShapeSource, setShowShapeSource] = useState(false);
  const shapeSourceRef = { current: null as ShapeSource | null };

  const handleRef = (ref: ShapeSource | null) => {
    shapeSourceRef.current = ref;
    if (ref) {
      // This would fail with "Unknown reactTag" before the fix
      ref.getClusterExpansionZoom(someFeature)
        .then((zoom) => console.log('Got zoom:', zoom))
        .catch((err) => console.error('Error:', err.message));
    }
  };

  return (
    <MapView style={{ flex: 1 }}>
      <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
      {showShapeSource && (
        <ShapeSource ref={handleRef} id="test" shape={features} cluster>
          <CircleLayer id="circles" />
        </ShapeSource>
      )}
    </MapView>
  );
};

Before fix:

[handleRef] Error #0: Unknown reactTag: 2502
[handleRef] Error #1: Unknown reactTag: 2502

After fix: View resolution succeeds, method executes normally.

Use polling-based view resolution instead of immediate lookup to fix "Unknown reactTag" errors when calling native methods immediately after receiving a ref callback.
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.

2 participants