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.

FlatList data changed but refresh indicator not shows automatically

See original GitHub issue

Is this a bug report?

when my flatList data changed, the layout changed but refresh indicator on top of flatList is not always shows loading automatically, I have to pull it down a little bit then the indicator stick on flatList, or it just shows at a blink when the data really changed, not shows at whole async data changed time as expected.

Have you read the Contributing Guidelines?

yes

Environment

  1. react-native -v: 0.46.0
  2. node -v: v6.9.1
  3. npm -v: 3.10.8
  4. yarn --version: 0.24.5
  • Target Platform: iOS android works fine

  • Development Operating System: macOS

  • Build tools: Xcode

Steps to Reproduce

  1. set refreshing state to true then call api, but refresh indicator on flatList not always automatically pull down
  2. api back then data changed, it pull down at a blink, set refreshing state to false

Expected Behavior

loading indicator should show right after api called.

Actual Behavior

it shows and disappear quickly on data changed.

 onRefresh = async () => {
    this.setState({
      isRefreshing: true
    });
    await this.props.searchProducts(this.state.searchString);
    await this.setState({
      data: this.props.products.searchProductsIds.map(
        id => this.props.products.searchProductsById[id]
      )
    });
   
    this.setState({
      isRefreshing: false
    });
   
  };

  <FlatList
      removeClippedSubviews={false}
      onRefresh={this.onRefresh}
      refreshing={this.state.refreshing}
      extraData={this.extraData}
      data={this.state.data}
      renderItem={this.renderItem}
      keyExtractor={product => product.id}
      contentContainerStyle={styles.listContainer}
      onEndReached={this.handleLoadMore}
      onEndReachedThreshold={5}
    />

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:28
  • Comments:31 (1 by maintainers)

github_iconTop GitHub Comments

54reactions
bolan9999commented, Dec 25, 2017

FlatList and SectionList is bad performance. Try this,please. may be it is a surprise for you

https://github.com/bolan9999/react-native-largelist

13reactions
whizdummycommented, Jul 9, 2018

Just pass onRefresh props. If you’re not using onRefresh, just pass onRefresh={ () => null }. refreshing props will now work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FlatList refreshing not showing when it's true during first load
The refresh indicator not showing even I've set the refreshing state to true in ProductList. But if I manually trigger from button click,...
Read more >
FlatList - React Native
FlatList. A performant interface for rendering basic, flat lists, supporting the most handy features: Fully cross-platform.
Read more >
React Native Pull-to-Refresh: Make Refreshing Easy for Users
The refreshing prop indicates whether the refresh is active or not. It should be set to true when you start fetching data and...
Read more >
Display a List Using the FlatList Component in React Native
Since FlatList is a PureComponent , it assumes that the data is an immutable object and that any change in data is done...
Read more >
How do I show an activity indicator every time my flatlist data ...
so your flatlist wont be shown since you set loading to true at the start of the function that gets the content, and...
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