Skip to content

docs: add fireEvent.scroll example for FlatList #223

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

Merged
merged 1 commit into from
Sep 27, 2019
Merged

docs: add fireEvent.scroll example for FlatList #223

merged 1 commit into from
Sep 27, 2019

Conversation

ajubin
Copy link
Contributor

@ajubin ajubin commented Sep 24, 2019

Summary

When testing scroll on a flatlist, I was getting the error : TypeError: cannot read property 'height' of undefined

Error thrown

image

Component tested

export class InfiniteScrollFlatList<Item> extends PureComponent<Props<Item>> {
  private handleLoadMore = () => {
    if (!this.props.isLoadingMore && this.props.nextPage) {
      this.props.fetchMore({ page: this.props.nextPage });
    }
  };

  private renderListFooter = () => {
    if (this.props.isLoadingMore) return <Loader />;
    return null;
  };

  public render() {
    return (
      <FlatList
        {...this.props}
        onEndReachedThreshold={0.2}
        onEndReached={this.handleLoadMore}
        ListFooterComponent={this.renderListFooter}
      />
    );
  }
}

Test plan

@thymikee
Copy link
Member

Hey! Thanks for sending that. The example though is about ScrollView, not FlatList. Could you verify that the scroll event is the same for scroll view and flat list?

@ajubin
Copy link
Contributor Author

ajubin commented Sep 25, 2019

Hello,

My example here is about FlatList. The contentSize and the layoutMeasurement are not needed for ScrollView. Should I had another example ?

@thymikee
Copy link
Member

Please add another example then :) Feel free to only mention the scroll event data differs between components, and e.g. for FlatList it looks like this.

@ajubin
Copy link
Contributor Author

ajubin commented Sep 27, 2019

@thymikee I've updated my pr

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thymikee thymikee changed the title doc(Scroll): complete fireEvent.scroll example docs: add fireEvent.scroll example for FlatList Sep 27, 2019
@thymikee thymikee merged commit 69d1480 into callstack:master Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants