我下面從陣營本土教程: https://facebook.github.io/react-native/docs/animated.html失敗道具類型:無效的道具`opacity`型`object`提供給`RCTView`
但是,我得到了以下警告,當我跑我的代碼: 失敗道具類型:提供給RCTView
和組件只是消失object
型的無效的道具opacity
沒有動畫時淡出()得到調用。
這裏是一個示例代碼:
import React, { Component } from 'react';
import {
AppRegistry,
Text,
View,
Animated,
StyleSheet
} from 'react-native';
import Icon from 'react-native-vector-icon/FontAwesome'
export default class Sample extends Component {
state = {
fadeAnim: new Animated.Value(0),
}
fade() {
Animated.timing( // Animate over time
this.state.fadeAnim, // The animated value to drive
{
toValue: 1, // Animate to opacity: 1 (opaque)
duration: 10000, // Make it take a while
}
).start(); // Starts the animation
}
render() {
let { fadeAnim } = this.state;
return (
<View style={styles.container}>
<TouchableHighlight onPress={() => {this.fade()}}>
<Icon name="circle" size={30} color="#fff" style={{opacity: fadeAnim}}
>
</TouchableHighlight>
</View>
);
}
......
}
問題解決了,非常感謝! – egbert