【问题标题】:React Native animation, render error: Invalid transform scaleDisliked: { "scaleDisliked":1 }React Native 动画,渲染错误:无效转换 scaleDisliked: { \"scaleDisliked\":1 }
【发布时间】:2023-02-02 00:55:21
【问题描述】:

在我的本机反应应用程序中,我想将 transform:scale 应用于 Animated.View 组件,我正在使用插值来实现此效果,但出现以下错误:

Render error: Invalid transform scaleDisliked: { "scaleDisliked":1 }

我的完整代码:

const animationDisliked = useRef(new Animated.Value(0)).current;
  const inputRangeDisliked = [0, 1];
  const outputRangeDisliked = [1, 0.8];
  
  //const scaleDisliked = animationDisliked.interpolate({inputRangeDisliked, outputRangeDisliked});

  const scaleDisliked = animationDisliked.interpolate({inputRange: inputRangeDisliked, outputRange: outputRangeDisliked});


<Animated.View  style={{ transform: [{scaleDisliked}],elevation:10,position:'absolute',right:10,width:95,height:95,borderRadius:95/2,backgroundColor:'white' }}>
                
                </Animated.View>

知道为什么我会收到此错误吗?

【问题讨论】:

    标签: javascript reactjs react-native


    【解决方案1】:

    转换列表中的对象缺少转换键,特别是:

    <Animated.View
      style={{
        transform = [
          {
            scale: scaleDisliked
          }
        ],
        // ...
      }}>
    </Animated.View>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-20
      • 1970-01-01
      • 1970-01-01
      • 2022-12-05
      • 2016-03-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多