Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarkerView is not compatible with createAnimatedComponent #643

Open
unendingblue opened this issue Feb 12, 2025 · 4 comments
Open

MarkerView is not compatible with createAnimatedComponent #643

unendingblue opened this issue Feb 12, 2025 · 4 comments

Comments

@unendingblue
Copy link

Describe and reproduce the Bug

This issue blocks migration from @rnmapbox/maps.

Using Reanimated's createAnimatedComponenton MarkerView does not work. More specifically:

  • MarkerView is a functional component and therefore is not supported out of the box. Only class components are compatible with createAnimatedComponent.
  • Using React's forwardRef does not work, causing the render errors Cannot read property 'getScrollableNode' of null and Cannot read property '__internalInstanceHandle' of null.

Having support for Reanimated is quite crucial from a UX point of view, especially when it comes to using useAnimatedProps on the marker's coordinates for smooth movement.

import React from 'react';
import Animated from 'react-native-reanimated';
import { MarkerView } from '@maplibre/maplibre-react-native';

const AnimatedMarkerView = Animated.createAnimatedComponent(
  React.forwardRef(MarkerView),
);

const AnimatedMarkerTestMap = () => {
  return (
    <MapView>
      <AnimatedMarkerView coordinate={[0, 0]}>
        [...]
      </AnimatedMarkerView>
    </MapView>
  );
};

Related issue: #334 (proposed solution is not a suitable substitute)

@maplibre/maplibre-react-native Version

10.0.1

Which platforms does this occur on?

No response

Which frameworks does this occur on?

Expo

Which architectures does this occur on?

Old Architecture

Environment

-
@lpatrun
Copy link

lpatrun commented Mar 7, 2025

@unendingblue
Have you tried this

const AnimatedMarkerView = Animated.createAnimatedComponent(MarkerView);

Or did you find other solution?

@unendingblue
Copy link
Author

@lpatrun Reanimated's createAnimatedComponent only accepts class-based components and RNML's implementation of MarkerView is functional. At the moment (prior to React 19) the solution is to use forwardRef, but it doesn't work in this case - unfortunately I haven't had time to investigate why that is.

@KiwiKilian
Copy link
Collaborator

I've started to cleanup the default RN Animated examples in #697 and also noticed missing forwardRef wrappings for MarkerView as well as the layers. So you did try to add forwardRef to MarkerView and that gave Cannot read property '__internalInstanceHandle' of null?

@unendingblue
Copy link
Author

@KiwiKilian Yep that's correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants