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