我正在尝试将我的图像堆叠在另一个之上,并实现轻扫(例如tinder)。但是我无法显示图片,相反,我只是得到警告,
功能无效,不能作为反应子代
import React, { Component } from 'react';
import {StyleSheet, Dimensions, View, Animated, Image } from 'react-native';
const SCREEN_HEIGHT = Dimensions.get('window').height
const SCREEN_WIDTH = Dimensions.get('window').width
//my images
const Users = [
{ id: "1", uri: require('./assets/image1.jpeg') },
{ id: "2", uri: require('./assets/image2.jpeg') },
{ id: "3", uri: require('./assets/image3.jpeg') },
{ id: "4", uri: require('./assets/image4.jpeg') },
]
export default class App extends Component {
render() {
//i tried doing this map outside render too , but did not work
const Images = Users.map((item, i) => {
return (
<Animated.View key={item.id} style={{ height: SCREEN_HEIGHT - 120, width: SCREEN_WIDTH, padding: 10, position:'absolute'}}>
<Image style={{ flex: 1, height: null, width: null, borderRadius: 20 }} source={item.uri} />
</Animated.View>
)
}
).reverse
return (
<View style={styles.container}>
<View style={{ height: 60 }}>
</View>
<View style={{ flex: 1 }}>
{Images} // not getting rendered here
</View>
<View style={{ height: 60 }}></View>
</View>
);
}
}
//styles
const styles = StyleSheet.create({
container: {
flex: 1,
}
});
我无法渲染我的图像,它显示警告功能无效,作为反应孩子