Search code examples
react-nativereact-native-flatlist

React native List footer component not rendering(funtion component)


I am trying to achieve pagination for infinite scrolling in react native. When loading, I want to render the loading spinner at the bottom of the Flat list component. (Note: I'm using Expo for this app)

const renderFooter = () => {
    if (!category.loading) return null;

    return (
      <View style={spinnerStyles.container}>
        <ActivityIndicator animating size="large" color="#0000ff" />
      </View>
    );
  };

  return (
    <View style={styles.container}>
      <FlatList
        columnWrapperStyle={{ justifyContent: "space-between" }}
        numColumns={2}
        data={category.data}
        renderItem={categoryItem}
        keyExtractor={(item) => item._id + item.sub_category}
        onEndReachedThreshold={0}
        listFooterComponent={renderFooter}
        onEndReached={() => loadMore()}
      />
    </View>
  );

The loading spinner not correctly working with the flat list footer. Has anyone run into this issue before, or does anyone have a solution?


Solution

  • Sorry, it's my simple syntax error. It's actually ListFooterComponent not listFooterComponent. Now it's working fine, Thank you.