Value cannot be cast from ReadableNativeMap to double

柔情痞子 提交于 2020-07-20 08:30:43

问题


I have a custom marker image and want to use a variable for the opacity of the image. I doing the following and gettin this error "Value for opacity cannot be cast from ReadableNativeMap to double"

var status=1;

  <MapView.Marker
         key={marker.latitude}
         coordinate={{ latitude: marker.latitude, longitude: marker.longitude }} 
         onPress={() => this.props.Quiz2(marker.latitude, marker.longitude)} >
    <View><Image source={require('../assets/icons/quiz.png')} style={{ width: 40, height: 40,opacity:status}}/></View>
</MapView.Marker>

enter image description here


回答1:


You have to use <Animated.*> e.g.

For <View> use <Animated.View>

For <Image> use <Animated.Image>

And so on. React Native will understand Animated.Value if it's used in Animated.* component.



来源:https://stackoverflow.com/questions/54272759/value-cannot-be-cast-from-readablenativemap-to-double

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!