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

Fix resolving ref to SVG components on Web #6885

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

piaskowyk
Copy link
Member

@piaskowyk piaskowyk commented Jan 10, 2025

Summary

In some cases, such as Layout Animation, we need a reference to the DOM component instead of the React component. However, for animations, we require a reference to the React component because sometimes we can directly on DOM component (JS Props). This PR adds a component field to accommodate both types of references.

Without:
Screenshot 2025-01-10 at 14 17 05

With:
Screenshot 2025-01-10 at 14 16 59

Test plan

Example code
import Animated, {
  FadeIn,
} from 'react-native-reanimated';
import { Circle, Svg } from 'react-native-svg';
import { StyleSheet, View } from 'react-native';

import React from 'react';

const AnimatedCircle = Animated.createAnimatedComponent(Circle);

export default function SvgExample() {
  return (
    <View style={styles.container}>
      <Svg height="200" width="200">
        <AnimatedCircle
          entering={FadeIn}
          cx="50%"
          cy="50%"
          fill="lime"
          r={100}
        />
      </Svg>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

@piaskowyk piaskowyk requested a review from m-bert January 13, 2025 11:49
@piaskowyk piaskowyk marked this pull request as ready for review January 13, 2025 11:53
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.

3 participants