question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inverted FlatList displays activity indicator at the bottom

See original GitHub issue

Is this a bug report?

yes

Have you read the Contributing Guidelines?

yes

Environment

Environment: all newer environments Packages: any packages Target Platform: any platform Version: 0.53.0 and all other versions of RN that support FlatList with the inverted attribute

Steps to Reproduce

  1. return <FlatList {...props} inverted data={[...]} refreshing={this.state.isLoading} onRefresh={this.someListUpdatingFunction} /> (just add the ‘inverted’ attribute to any RN <FlatList/> to reproduce, then try pulling down to refresh, then try pulling up to refresh)

Expected Behavior

onRefresh should allow users to refresh using the most common way that users have been trained to refresh data over the years, which is to “pull down to refresh” and see an ActivityIndicator spinning above the FlatList, never below it… this should be the default even when inverted={true}

Actual Behavior

user has to pull UP to refresh (with Activity Indicator at the bottom) … literal vs intuitive: when taken “literally”, i can agree that this is expected behavior since it is after all “inverted” … however, when taken “intuitively”, it’s not so expected, especially for users… I don’t think app users have ever been trained to pull up to refresh data, except for maybe in the “OfferUp” chat app!

Most Applicable Use Case

  • a chat app, where users pull down to load more chat history that’s appended above, similar to how it’s done in iOS Messages app
  • UIs like terminals, event logs, chat, etc… where it’s common to insert new content from the bottom and load old content when the user scrolls to the top or pulls down to refresh

Demo

https://snack.expo.io/S1UOyWgSM (to reproduce, just add the ‘inverted’ attribute to any RN <FlatList/> component using v0.53.0 or any version of RN that supports FlatList)

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:9
  • Comments:40 (7 by maintainers)

github_iconTop GitHub Comments

12reactions
ChenLi0830commented, Nov 28, 2018

Inspired by @mrozbarry, here is what I did as a workaround.

const { fetchingMore, onFetchMore } = this.props;
return <ScrollView
  contentContainerStyle={{
    flexDirection: 'row',
    alignSelf: 'flex-end',
    flexGrow: 1
  }}
  refreshControl={<RefreshControl refreshing={fetchingMore} onRefresh={onFetchMore} />}
>
  <FlatList
    inverted
    style={styles.list}
    data={messages}
    keyExtractor={this.extractItemKey}
    renderItem={this.renderItem}
  />
</ScrollView>

Note that it’s important to have the flexGrow: 1 style in scrollView, otherwise the FlatList would flow at the top of the scrollview when it’s not full.

9reactions
dozoischcommented, Oct 18, 2018

I personally think the behavior of the RefreshControl being at the bottom makes sense. When you are in a Chat application, where new messages appear at the bottom and you keep the user scrolled at the bottom, it feels natural to pull from the bottom to up to try to refresh the conversation. Slack implements it like that. Having a RefreshControl at the top is impossible due to scrolling top causing to load more messages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to show ActivityIndicator at the bottom of the list in FlatList?
I am trying to display ActivityIndicator when the list reaches the bottom. However, currently it loads without showing the spinner.
Read more >
[Solved]-FlatList refresh indicator is blocking touch event after ...
FlatList refresh indicator is blocking touch event after the indicator disappears · Scroll to end of FlatList after displaying the keyboard · React...
Read more >
FlatList - React Native
Scrolls to the item at the specified index such that it is positioned in the viewable area such that viewPosition 0 places it...
Read more >
How to build a customized React Native activity indicator
React Native offers ActivityIndicator to display a circular loading indicator for longer action-response times. The ActivityIndicator plays the ...
Read more >
MessageList | Stream Chat - React Native SDK Docs
Since we use inverted FlatList, this component will be rendered at bottom of the list. In absence of this prop, an inline loading...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found