1

我正在尝试使用 reanimated 来控制 ScrollView Value。在 iOS 上工作正常,但 android 抛出此错误:

java.lang.double cannot be cast to java.lang.boolean

这是代码:

import React, { PureComponent } from 'react'
import { StyleSheet, Text, ScrollView} from 'react-native'
import Animated, {event, set} from 'react-native-reanimated'
import {
  PanGestureHandler,
  NativeViewGestureHandler,
} from 'react-native-gesture-handler'

class ComponentName extends PureComponent {
  scrollEnabled = new Value(0)
  panRef = React.createRef<PanGestureHandler>()
  listRef = React.createRef<ScrollView>()

  onGestureEvent = event(
    // some event with conditions...
    set(this.scrollEnabled, 1)
    // ... 
  )
  
  render () {
    return (
      <PanGestureHandler
        onGestureEvent={this.onGestureEvent}
        ref={this.panRef}
        simultaneousHandlers={this.listRef}
      >
        <Animated.ScrollView
          scrollEnabled={this.scrollEnabled}
          simultaneousHandlers={this.panRef}
        >
          <Text>ComponentName</Text>
          <Text>ComponentName</Text>
          <Text>ComponentName</Text>
          <Text>ComponentName</Text>
          ...
        </Animated.ScrollView>
      </PanGestureHandler>
    )
  }
}

我如何使它工作?

在此处输入图像描述

4

0 回答 0