这些是我的代码:
class StarListScrollViewCell extends Component{
static propTypes = {
dateSource : React.PropTypes.array
}
constructor(props){
super(props);
this.state = {
starSide : 20,
}
}
addStar(){
LayoutAnimation.spring();
this.setState({starSide: this.state.starSide + 10});
}
componentWillMount() {
LayoutAnimation.spring();
}
render(){
return(
<View style={{backgroundColor: 'white' , height: 70 , width : Dimensions.get('window').width,flexDirection:'row'}}>
<TouchableOpacity style={{backgroundColor: 'red' ,width:Dimensions.get('window').width/7,justifyContent:'center',alignItems:'center'}}
onPress = {this.addStar()}>
<Image source={require('./star-gray.png')}
style ={{width:this.state.starSide,
height:this.state.starSide,
justifyContent:'center',alignItems:'center'}}>
</Image>
</TouchableOpacity>
</View>
);
}
}
单击按钮时遇到错误。我参考https://facebook.github.io/react-native/releases/next/docs/animations.html编写它