我正在尝试使用View组件样式动画.我按照这里列出的例子: https://facebook.github.io/react-native/docs/animations.html 但是,当我渲染我的组件时,我得到错误: [tid:com.facebook.React.ShadowQueue][RCTConvert
但是,当我渲染我的组件时,我得到错误:
[tid:com.facebook.React.ShadowQueue][RCTConvert.m:55] Error setting property ‘height’ of RCTView with tag #7: JSON value ‘{
“_animation” = “”;
“_children” = (
);
“_listeners” = {
};
“_offset” = 0;
“_value” = 200;
}’ of type NSDictionary cannot be converted to NSNumber
这就是我在构造函数中设置Animated值的方法:
constructor() { super(); this.state = { titleContainerHeight: new Animated.Value(200), } }
以下是我的看法:
<View style={[styles.titleContainer,{height:this.state.titleContainerHeight}]}> <Text style={[{color: 'white'}]}>App logo here</Text> </View>
好像我正在处理文档描述的所有内容,而且我在另一个组件中做同样的事情而没有出现任何错误.那么,这里有什么问题?
啊没关系,我发现我做错了什么.我忘了专门使用“Animated.View”组件.这有效:<Animated.View style={[styles.titleContainer,{height:this.state.titleContainerHeight}]}> <Text style={[{color: 'white'}]}>App logo here</Text> </Animated.View>