react-native - React Native Expo Animated _reactNative.Animated.interpolate 不是函数
问题描述
尝试为视图的标题设置动画时出现此错误。TypeError:_reactNative.Animated.interpolate 不是函数
我尝试使用 react-native HOOKS 遵循本教程https://www.youtube.com/watch?v=JPx8IlfYQ-c,我也尝试使用 react-native-reanimated 没有成功。我正在使用带有 react 16.8.3 的 expo sdk 35.0.0 并尝试使用 react-native-reanaimeted: 1.7.0 但在此示例中,我直接从 react-native 导入了 import {Animated} from 'react-native'
import React, {useState, useEffect} from 'react';
import {
StyleSheet,
Text,
View,
TouchableOpacity,
Image,
FlatList,
Animated,
TouchableWithoutFeedback
} from 'react-native';
const HEADER__HEIGHT = 70
const KitCardItem = ({student, onPressCard, insertItemDialogVisible, setinsertItemDialogVisible}) => {
const {date, items} = student || {};
const [itemsVisible, setItemsVisible] = useState(true)
const scrollY = new Animated.Value(0)
const headerY = Animated.interpolate(scrollY, {
inputRange: [0, HEADER__HEIGHT],
outputRange: [0, -HEADER__HEIGHT],
})
return (
<View style={{height: '100%', justifyContent: 'center'}}>
<Animated.View style={{
height: HEADER__HEIGHT,
transform: [{translateY: headerY}]
}}>
<View
style={{width: '100%', alignItems: 'center'}}>
<Text style={{fontWeight: '700', fontSize: 16, fontcolor: titleColor}}>{getDateTitle()}</Text>
</View>
</Animated.View>
<View style={{flex: 1,}}>
<Animated.FlatList
scrollEventThrottle={16}
onScroll={ Animated.event([
{
nativeEvent: {contentOffset: {y: scrollY}}
}
])}
listKey={(item, index) => item._id}
showsHorizontalScrollIndicator={false}
vertical
style={{flex: 1,}}
data={items}
renderItem={({item, index}) => renderItem(item, index)}/>
</View>
{items.length === 0 &&
<View style={emptyContainer}>
<EmptyState
message={'Ainda sem notas para esse dia.'}
/>
</View> }
</View>
)
}
const styles = StyleSheet.create({});
export default KitCardItem
解决方案
react-native-reanimated 更改Animated.interpolate
为Animated.interpolateNode
推荐阅读
- jekyll - 如何使用 Liquid 对 Jekyll 的数据项进行分页
- mongodb - 如何在 DynamoDB 中存储任意结构的 API 响应
- angularjs - 如何使用meteorjs、AWS s3和Angularjs下载大文件?
- angular - Filter *ngFor from array object
- javascript - 使用 id 变量的“querySelectorAll”上的无效选择器
- r - 如何使用颜色选择器生成代码颜色字符
- ios - Swift - Creating custom functions for NSExpression
- python - Python: Binarize image and fill shapes
- amazon-web-services - 如何将数据从 Google Cloud Storage 传输到 Amazon S3 并获得相关费用?
- php - 从 php 数据文件中获取特定的键和值到 js