I’m trying to postion an element correctly using transform property,
but whenever i give percentage values it giving me an error
How can I fix this issue ?
Here is my code
import { Animated,Image,View} from "react-native";
<Animated.View
style={{
position: "absolute",
right: 20,
top: "50%",
transform: [{ translateY: "-50%" }],
}}
>
{captchaImage && (
<Image
source={{ uri: captchaImage }}
style={{
width: 50,
height: 24,
resizeMode: "contain",
}}
/>
)}
</Animated.View>
Screenshot of simulator is attached below.
did anyone have faced similar issue ?
2
Answers
TranslateY cannot be a string. Make it a number.
https://reactnative.dev/docs/transforms
TranslateY must be a number. If you want it to be 50% of screen height you can use something like this.
For more info about Dimensions check out the link.