请帮助; 我试图通过react-native-auto-height组件设置高度auto,但是我得到的与我期望得到的有很大不同。
这是FeedCard.js:
const PicsCardContent = styled(Touchable).attrs({
feedback: 'opacity'
})`
width: ${9*width/28};
borderWidth: 1;
borderColor: ${props => props.theme.WHITE};
backgroundColor: ${props => props.theme.WHITE};
marginBottom: 10;
borderRadius: 4;
`
function FeedCard({ user }) {
return(
<Root>
<PicsCardContent>
<AutoHeightImage width={9*width/28} imageURL={ user.image }/>
</PicsCardContent>
</Root>
);
}
这是HomeScreen.js:
class HomeScreen extends Component {
_renderItem = ({ item }) => <FeedCard {...item} />
return (
<Root>
<FlatList
contentContainerStyle={{ alignSelf: 'stretch'}}
data={data.getPosts}
keyExtractor={item => item._id}
renderItem={this._renderItem}
numColumns={3}
/>
</Root>
);
}
}
我附上了截图; 感谢帮助。enter image description here