Skip to content

FlatList onRefresh not called on pull up. #14756

Closed
@dmr07

Description

Is this a bug report?

Yes

Have you read the Bugs section of the Contributing to React Native Guide?

Yes

Environment

  1. react-native -v: 0.4.5
  2. node -v: 7.4.0
  3. npm -v: 5.0.3
  4. yarn --version (if you use Yarn): 0.24.5

Then, specify:

  1. Target Platform (e.g. iOS, Android): iOS
  2. Development Operating System (e.g. macOS Sierra, Windows 10): macOs Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant): XCode 8.3.3

Steps to Reproduce

  1. Implement React-Native FlatList in a module.
  2. Render a component in renderItems prop
  3. nest FlatList inside <ScrollView> element
  4. Pull up on device to attempt to refresh

Expected Behavior

Call onRefresh function on pull up.

Actual Behavior

onRefresh function is not called.

Reproducible Demo

Snack Link: https://snack.expo.io/HJYx3Kx4W

...
  constructor(props) {
    super(props);
    this.state = {
      stories: [],
      isFetching: false,
    };
  }
  componentDidMount() { this.fetchData() }
  onRefresh() {
    this.setState({ isFetching: true }, function() { this.fetchData() });
  }
  fetchData() {
    var that = this;
    axios.get('http://192.168.0.13:3000/api/story/get/by/geo')
      .then((res) => {
        that.setState({ stories: res.data, isFetching: false });
        that.props.dispatch(StoryActions.setStories(res.data))
      })
  }
  render() {
    return (
      <ScrollView>
        <FlatList
          onRefresh={() => this.onRefresh()}
          refreshing={this.state.isFetching}
          data={this.state.stories}
          keyExtractor={(item, index) => item.id}
          renderItem={({item}) => (<StoryFeed story={item} id={item.id} /> )}
          />
      </ScrollView>
    )
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions