-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inverted FlatList displays activity indicator at the bottom #17553
Comments
Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version? I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer. |
Looks like this may have been closed too eagerly -- the bot didn't see if v53 or newer was used in your issue description. I'd still argue it's unclear to mention "newer versions" without being explicit, so I'll leave this closed. Please do re-open and make sure to include a specific version. |
Hi, I have reproduced the same problem on V53! |
This issue is straddling the line between bug report and feature request. I'll therefore mark it as a Good first issue for someone to tackle if they would like to get their feet wet with making contributions to React Native. |
@hramos thank you for keeping this alive! I may be able to tackle this in a few weeks, but rather than changing the current behavior, I would just provide other developers with the option to choose for themselves which behavior they prefer between [pull up to refresh] or [pull down to refresh], while in |
@hramos I would love to work on this as my first issue, but is there a guide for building the React-Native source for iOS? All I see are the steps for Android. |
I don't think we have a guide for that, but building from source for iOS may not be necessary if the fix only involves JavaScript. Open Then open the Flat List Example: Confirm everything works as expected. You may need to follow the instructions for installing your fork of React Native: http://facebook.github.io/react-native/docs/android-building-from-source.html#1-installing-the-fork Then you can proceed to add your changes to Thanks for letting me know these instructions need to be expanded! Let me know how it goes and we can work on improving the docs. |
@hramos will do! Thanks for the info |
If this has not been fixed .I would like to start working on this. Can someone confirm? |
@himanshuchauhan feel free. I spent an hour or two looking at it, but it seemed to me I couldn't do it with just Javascript, and then work and life happened. Curious to your solution if you end up doing it! |
I have been trying to fix this . But I am having issues running the
|
If anybody else isn't, I'll be taking a look at this |
I don't think this can be solved with a purely Javascript implementation. The inverted attribute causes a scale transform of -1 on the ScrollView (which is then undone by each cell Item inside to make the cell appear upright). Since the activity indicator would normally appear at the top, it now appears below. The activity indicator is being generated by the RefreshControl component attached to the ScrollView. A fix that I have in mind is changing the location of the frame of the RefreshControl, as discussed here, but I haven't had success doing that. From there we would have to change how RefreshControl triggers a refresh (which normally occurs when Somebody else can take another try at this. There might be a simpler approach, but the main issue is from the scale transform of -1. |
Is it really a bug at all? Inverted could mean an inverted refresh either |
@briank621 I thought the exact the same thing. I didn't spend a ton of time looking at it, but remember at the time I didn't think it could be done solely in JS without doing some hackey things. I'll try to take a peak again and maybe build React-Native from source when I have time. |
Thanks for posting this! It looks like your issue may be missing some necessary information. Can you run Thank you for your contributions. |
Instruction for installing the forked version in this comment is broken. Could someone direct me where I can find it? |
In WhatsApp Inverted FlatList (image on the right) Pull Down displays the older chat history. In WhatsApp Inverted FlatList (image on the right) Pull Up triggers the refresh: I agree that the |
export default function App() {
const [refreshing, setRefreshing] = useState(false);
const screenHeight = Dimensions.get('window').height;
const onRefresh = () => {
setRefreshing(true)
}
return (
<FlatList
data={POSTS}
renderItem={({ item }) => <Item data={item} />}
keyExtractor={item => item.id}
refreshControl={<RefreshControl progressViewOffset={screenHeight - 100} refreshing={refreshing} onRefresh={onRefresh} />}
inverted
/>
);
} You can try the following snack on an
|
I don't have any context on If that existed on iOS does that feel like a more proper solution to this problem? I'd like to avoid adding yet-another-prop to FlatList in #28857 if there is an existing prop that is intended to enable this behavior. |
Yes, but it does not work on iOS with the changes to iOS Developer should check the Currently I am working on a pull request for #18266 (comment) and CircleCI, so I would avoid working with iOS. Thanks a lot 😃 I wish you a good weekend 😃 |
I thought the same but it only works on android and not iOS. Also when i use |
changes included in 1d22f8f broke
#11356 was meant to fix iOS, but never made it to master I'll be happy to implement changes for Android if they will be merged in master. |
Any update on this issue? |
Just ran into this issue in RN 0.62.2. I believe @ChenLi0830 's workaround isn't the best solution due the Nested VirtualizedList warning ('VirtualizedLists should never be nested inside plain ScrollViews') |
Is some working on this? If not, I'd like to work on this. |
Aha, I solved this problem with the following code: <FlatList
ref={this.messageList}
style={styles.list}
contentContainerStyle={styles.listContent}
data={messages}
renderItem={renderItem}
inverted={true}
keyExtractor={(item) => item.id.toString()}
onEndReached={this.fetchMoreMessages}
ListFooterComponent={<ActivityIndicator />}
ListFooterComponentStyle={{ flexGrow: 1, paddingTop: 20 }}
/> |
IMO refresh is, as its name indicates, intended for fresh, new data. It doesn't make sense to use this for past data. |
i solved it by using
|
I've used flexGrow instead of flex, flex blocks scrolling :( |
Damn its 4 years and still no native solution from facebook... |
What is the status of this issue ? labels added mention it as a |
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
attributeSteps to Reproduce
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
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)The text was updated successfully, but these errors were encountered: