react-native - 如何修复 React Native 中的 "transform with key of translatex must be a number"错误?

标签 react-native animation react-native-android transform

我正在尝试在 React Native 中制作翻译动画。
这是我的代码

const scrollX = React.useRef(new Animated.Value(0)).current;

<Animated.ScrollView
     horizontal
     snapToInterval={width}
     onScroll={Animated.event(
        [{ nativeEvent: { contentOffset: { x: scrollX } } }],
        { useNativeDriver: false }
        )}
     scrollEventThrottle={16}
  ></Animated.ScrollView>

  <Animated.View style={{ transform: [{ translateX: multiply(scrollX, -1) }] }}>
          <Text>Some text</Text>
  </Animated.View>
我收到此错误 transform with key of translatex must be a number如果我将 multiply(scrollX, -1) 更改为 scrollX,动画就会反转,
我该如何解决这个问题?

最佳答案

我有这个问题,只是因为我忘了给 Animated.View

关于react-native - 如何修复 React Native 中的 "transform with key of translatex must be a number"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63745653/

相关文章:

reactjs - React Native 选择器和控制台显示相同状态的不同值

javascript - Craftyjs Sprite 动画问题

javascript - 单击幻灯片更改时延迟动画

javascript - React Native 无限滚动问题与少数元素

javascript - React native——动态添加onPress View

ios - 使用 Windows 为 IOS 构建 Expo 应用程序

iphone - UITableView beginUpdates/endUpdates 回调

react-native - 在React Native中与Android OS设置链接

android - 设置 admob 后,我的应用程序崩溃而没有错误

react-native - 如何返回 webview?我在 react-native 中使用 react-navigation 包