Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native “错误”;尝试分配给只读属性;在React Native中使用插值时_React Native_Interpolation_React Native Animatable - Fatal编程技术网

React native “错误”;尝试分配给只读属性;在React Native中使用插值时

React native “错误”;尝试分配给只读属性;在React Native中使用插值时,react-native,interpolation,react-native-animatable,React Native,Interpolation,React Native Animatable,我有一个FlatList和它上面的视图。我想要的就是当向下滚动平面列表时,视图的高度降为零。我使用插值来实现这一点,下面是我的代码: ... const scorllY = useRef(new Animated.Value(0)).current; const getCounterHeight = () => { return scorllY.interpolate({ inputRange: [0, 50], outpu

我有一个
FlatList
和它上面的
视图。我想要的就是当向下滚动
平面列表时,
视图的高度降为零。我使用插值来实现这一点,下面是我的代码:

...
const scorllY = useRef(new Animated.Value(0)).current;
 const getCounterHeight = () => {
        return scorllY.interpolate({
            inputRange: [0, 50],
            outputRange: [25, 0],
            extrapolate: 'clamp'

        })
    }

     <View style={{ ...styles.update, height: getCounterHeight }}>
         ...
     </View>
     <Animated.FlatList data={rankList} keyExtractor={item => item.id}
                    renderItem={({ item }) => (
                        <UserRankInfo id={item.id} username={item.name} point={item.point} />
                    )} showsVerticalScrollIndicator={false} scrollEventThrottle={16}
                    onScroll={Animated.event(
                        [
                            {
                                nativeEvent: { contentOffset: { y: scorllY } }
                            }
                        ], { useNativeDriver: true }
                    )} />
。。。
const scorly=useRef(新的动画.Value(0)).current;
常量getCounterHeight=()=>{
返回scorly.interpolate({
输入范围:[0,50],
输出范围:[25,0],
推断:“钳子”
})
}
...
项目id}
renderItem={({item})=>(
)}showsVerticalScrollIndicator={false}scrollEventThrottle={16}
onScroll={Animated.event(
[
{
nativeEvent:{contentOffset:{y:scorly}}
}
],{useNativeDriver:true}
)} />

当我运行代码时,我得到了这个错误。有人能告诉我如何修复吗?

尝试将其更改为
?此外,您应该执行
const getCounterHeight=scorly.interpolate({inputRange:[0,50],outputRange:[25,0],ext外推法:'clamp'})
@Harrison在更改为
后,我收到此错误
本机动画模块不支持样式属性“height”
。因此我无法设置视图高度的动画?使用
useNativeDriver:true
只能使用变换和缩放,因此必须将其设置为false