Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListEmptyComponent not taking full screen with flex 1 in React Native Section List

So I am using React Native Section List and following is my Code of ListEmptyContent

// define your styles
const styles = StyleSheet.create({
  container: {
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff',
    marginLeft: 10,
    marginRight: 10,
  },
  imageStyle: {
    width: 140,
    height: 120,
  },
  titleStyle: {
    fontSize: 14,
    color: '#363a45',
  },
  subTitleStyle: {
    fontSize: 12,
    color: '#898d97',
  },
});
// create a component
const GPEmtptyTransaction = ({ firstLine, secondLine }) => {
  return (
    <View style={styles.container}>
      <Image source={images.emptyTransactionIcon} style={styles.imageStyle} />
      <Text style={styles.titleStyle}>{firstLine}</Text>
      <Text style={styles.subTitleStyle}>{secondLine}</Text>
    </View>
  );
};

But when EmptyTemplate is rendered it is rendered on Top and not stretching to full screen.

like image 942
vinod8812 Avatar asked Dec 07 '17 05:12

vinod8812


People also ask

What is a flat list?

FlatList is used to render the items in a scrollable list view. Large Data: When we have a large list of data and the number of data can change over time we can use FlatList as large data affect rendering speed and using FlatList won't affect the rendering speed.

Which interface do FlatList and SectionList extend from?

We use Sectionlist and Flatlist in our react native project and we use websocket to receive/update data.


1 Answers

This works for me, apply flexGrow: 1 to contentContainerStyle

<FlatList
    data={this.props.operations}
    contentContainerStyle={{ flexGrow: 1 }}
    ListEmptyComponent={<EmptyPlaceHolder />}
    renderItem={this.renderOperationItem} />
like image 153
Kishan Vaghela Avatar answered Sep 18 '22 09:09

Kishan Vaghela