Closed
Description
Is this a bug report?
Yes
Have you read the Bugs section of the Contributing to React Native Guide?
Yes
Environment
react-native -v
: 0.4.5node -v
: 7.4.0npm -v
: 5.0.3yarn --version
(if you use Yarn): 0.24.5
Then, specify:
- Target Platform (e.g. iOS, Android): iOS
- Development Operating System (e.g. macOS Sierra, Windows 10): macOs Sierra
- Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant): XCode 8.3.3
Steps to Reproduce
- Implement React-Native FlatList in a module.
- Render a component in renderItems prop
- nest FlatList inside
<ScrollView>
element - 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