我想将 2 个组件放在彼此下方。我的组件看起来像这样:
import React from 'react';
import {connect} from 'react-redux';
import {Text, StyleSheet, View, ListView, Switch, TextInput} from 'react-native';
import {List, ListItem} from 'native-base';
import SearchBar from '../shared/search-bar';
const mapStateToProps = (state) => {
return {
movies: state.movies.movies
};
};
const mapDispatchToProps = (dispatch) => {
return {};
};
const Component = ({movies}) => {
return (
<View style={styles.container}>
<SearchBar style={styles.searchBarContainer}/>
<List
style={styles.list}
dataArray={movies}
renderRow={movie => <ListItem><Text>{movie.title}</Text></ListItem>}
/>
</View>
);
};
let styles = StyleSheet.create({
container: {
flexDirection: 'column',
flex: 1,
},
searchBarContainer: {
flex: 0
},
list: {
flex: 1
}
});
export default connect(mapStateToProps, mapDispatchToProps)(Component);
出于某种原因,当它们被呈现时,列表只是在搜索栏上呈现。为什么 flexDirection:'column' 没有将它们放在彼此下方?
我觉得我在 flexbox 布局方面遗漏了一些东西。