Value cannot be cast from ReadableNativeMap to double
Asked Answered
P

1

8

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>

Prowess answered 20/1, 2019 at 1:13 Comment(2)
use status = 1.0 instead.Global
did you try to use Animated.Image instead of Image?Ro
C
10

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.

Cosimo answered 5/4, 2020 at 13:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.