Skip to content

Fix resolving ref to SVG components on Web#6885

Merged
piaskowyk merged 6 commits intomainfrom
@piaskowyk/fix-component-ref-for-svg
Jan 28, 2025
Merged

Fix resolving ref to SVG components on Web#6885
piaskowyk merged 6 commits intomainfrom
@piaskowyk/fix-component-ref-for-svg

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
@piaskowyk piaskowyk added this pull request to the merge queue Jan 28, 2025
Merged via the queue into main with commit 47cc2f9 Jan 28, 2025
9 checks passed
@piaskowyk piaskowyk deleted the @piaskowyk/fix-component-ref-for-svg branch January 28, 2025 19:57
r0h0gg6 pushed a commit to r0h0gg6/react-native-reanimated that referenced this pull request Jul 28, 2025
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