我想用svg
处理一个Animated
组件。但我收到此错误消息:
如果没有父节点,则无法将没有YogaNode的子节点添加到父节点 测量功能! (尝试将
RNSVGCircle
添加到RCTView
)。
这是我的代码:
import { PanResponder, View, Dimensions, TouchableOpacity,Animated } from 'react-native'
import Svg, { Path, Circle, G, Text, Image } from 'react-native-svg'
<Animated.View
style={{transform: [{translateX: translateX}],width:widthHeight, height: widthHeight}} {...this._panResponderTwo.panHandlers}>
<Circle
r={widthHeight}
cx={widthHeight}
cy={widthHeight}
fill="#ff0000"
{...this._panResponderTwo.panHandlers}
/>
</Animated.View>
答案 0 :(得分:0)
您可以使用createAnimatedComponent
函数:
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
const AnimatedG = Animated.createAnimatedComponent(G);
<AnimatedCircle
r={widthHeight}
cx={widthHeight}
cy={widthHeight}
fill="#ff0000"
{...this._panResponderTwo.panHandlers}
/>